I've integrated the Wordpress database directly with my .NET application.

What I want is to set the featured image of a post. This featured image must be maximum 800pixels wide, and automatically sized to that width (keeping the correct width/height ratio).

Medium size is set tp 300x300 Large size is set to 1024x1024

What I did now is go to Settings > Media and set the width of Thumbnail size to 600 and unchecked the checkbox Crop thumbnail to exact dimensions (normally thumbnails are proportional).

Now when I upload a new featured image, where can I find the filename of the image with a width of 600px and how can I retrieve it via SQL?


I see these rows in [wp_postmeta]

meta_id post_id meta_key                meta_value
76      16      _wp_attached_file       2014/01/sitelargeblah.png
77      16      _wp_attachment_metadata a:5:{s:5:"width";i:1920;s:6:"height";i:1643;s:4:"file";s:25:"2014/01/sitelargeblah.png";s:5:"sizes";a:4:{s:9:"thumbnail";a:4:{s:4:"file";s:25:"sitelargeblah-175x150.png";s:5:"width";i:175;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:6:"medium";a:4:{s:4:"file";s:25:"sitelargeblah-300x256.png";s:5:"width";i:300;s:6:"height";i:256;s:9:"mime-type";s:9:"image/png";}s:5:"large";a:4:{s:4:"file";s:26:"sitelargeblah-1024x876.png";s:5:"width";i:1024;s:6:"height";i:876;s:9:"mime-type";s:9:"image/png";}s:14:"post-thumbnail";a:4:{s:4:"file";s:25:"sitelargeblah-604x270.png";s:5:"width";i:604;s:6:"height";i:270;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:10:{s:8:"aperture";i:0;s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";i:0;s:9:"copyright";s:0:"";s:12:"focal_length";i:0;s:3:"iso";i:0;s:13:"shutter_speed";i:0;s:5:"title";s:0:"";}}

I see the 300px width and the 1024px width, but no 800px width of the thumbnail. Why not?

I can not simply append 800x800 after the value in _wp_attached_file, since the resized image is not an exact square, but with dimensions ratios preserved.

  • Do you need to get the image from WordPress or from your .NET application?
    – s_ha_dum
    Jan 5, 2014 at 17:23
  • I run a SQL query from my .NET application directly on the Wordpress database.
    – Adam
    Jan 5, 2014 at 21:06
  • 1
    Why not just use the 1024 and size it with css. You could also use something like timthumb to do it on the fly. binarymoon.co.uk/projects/timthumb Jan 5, 2014 at 22:35
  • @JacobRambo: thanks, I went for the CSS solution, less hassle than getting the JSON string from MySQl and breaking it down to extract the needed value. And thanks as well for the TimThumb tip :)
    – Adam
    Jan 6, 2014 at 8:45

1 Answer 1


In the post meta you can find the, attachment ID, you need lockup the org file name, and then ether loop throw the images sizes (In the meta data of the attachment) or append -600x600 to the file name if upload and image bigger then 600.

  • I updated my post (used 800px instead of 600px). But I don't see the value which I can use...
    – Adam
    Jan 5, 2014 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.