WordPress.org

Ready to get started?Download WordPress

Forums

Accessing wp_attachment_metadata information (post_thumbnail) (2 posts)

  1. szussino
    Member
    Posted 1 year ago #

    WordPress stores the thumbnails that it creates when an image is uploaded to the media gallery.

    How do I get the small image URL?

    It doesn't make any sense why WordPress creates all these thumbnails (waste of resources) if there is not a function to access them to use in your theme.

    This is a record in the mySQL database export:

    I can see, "post-thumbnail", "full-orig", and "homecat".

    (325725,69110,'_wp_attachment_metadata','a:6:{s:5:\"width\";s:3:\"208\";s:6:\"height\";s:3:\"300\";s:14:\" \";s:22:\"height=\'96\' width=\'66\'\";s:4:\"file\";s:31:\"2012/08/Iogo-e1345602784854.jpg\";s:5:\"sizes\";a:2:{s:14:\"post-thumbnail\";a:3:{s:4:\"file\";s:16:\"Iogo-150x120.jpg\";s:5:\"width\";s:3:\"150\";s:6:\"height\";s:3:\"120\";}s:7:\"homecat\";a:3:{s:4:\"file\";s:16:\"Iogo-121x175.jpg\";s:5:\"width\";s:3:\"121\";s:6:\"height\";s:3:\"175\";}}s:10:\"image_meta\";a:10:{s:8:\"aperture\";s:1:\"0\";s:6:\"credit\";s:0:\"\";s:6:\"camera\";s:0:\"\";s:7:\"caption\";s:0:\"\";s:17:\"created_timestamp\";s:1:\"0\";s:9:\"copyright\";s:0:\"\";s:12:\"focal_length\";s:1:\"0\";s:3:\"iso\";s:1:\"0\";s:13:\"shutter_speed\";s:1:\"0\";s:5:\"title\";s:0:\"\";}}'),(325726,69110,'_wp_attachment_backup_sizes','a:1:{s:9:\"full-orig\";a:3:{s:5:\"width\";s:3:\"225\";s:6:\"height\";s:3:\"323\";s:4:\"file\";s:8:\"Iogo.jpg\";}}'),(325727,69109,'_jd_post_meta_fixed','true'),

    Any ideas?

  2. The attachment meta data is saved as a serialized array which can be pasted into an online unserializer if you want to see the full array. I use http://blog.tanist.co.uk/files/unserialize/index.php.

    This is what it looks like back in an array ( this is random data not yours).

    Array
    (
    [width] => 1500
    [height] => 1125
    [hwstring_small] => height='96' width='128'
    [file] => 2012/07/rubbish.jpg
    [sizes] => Array
    (
    [thumbnail] => Array
    (
    [file] => rubbish-150x150.jpg
    [width] => 150
    [height] => 150
    )
    
    [medium] => Array
    (
    [file] => rubbish-300x225.jpg
    [width] => 300
    [height] => 225
    )
    
    [large] => Array
    (
    [file] => rubbish-1024x768.jpg
    [width] => 1024
    [height] => 768
    )
    
    [featured] => Array
    (
    [file] => rubbish-170x170.jpg
    [width] => 170
    [height] => 170
    )
    
    [mini-thumb] => Array
    (
    [file] => rubbish-110x110.jpg
    [width] => 110
    [height] => 110
    )
    
    [post-thumbnail] => Array
    (
    [file] => rubbish-265x200.jpg
    [width] => 265
    [height] => 200
    )
    )
    [image_meta] => Array
    (
    [aperture] => 3.5
    [credit] =>
    [camera] => DSC-T9
    [caption] =>
    [created_timestamp] => 1290602180
    [copyright] =>
    [focal_length] => 6.33
    [iso] => 80
    [shutter_speed] => 0.01
    [title] =>
    )
    )

    See wp_get_attachment_img_src()

Topic Closed

This topic has been closed to new replies.

About this Topic