I have two minimum image sizes to play with. One is 420x640px ("standing") and the other one is 980x420px ("landscape"). The normal loop with a regular layout is in place in my theme.

The goal is to produce a layout for a single post that first check the size of the featured image (ie. "check if post has featured image size max width of 420px, if true addclass layout-single-post-standing" or something like that).

I have been reading about responsive design but I am a beginner when it comes to that. Do any of you have an idea on where to start with this?

UPDATE: Dictating layout based on the size of a featured image could be considered a flimsy mechanism. As it panned out this method worked very well. By making use of the built-in twentyten_header_image_width feature (functions.php) and extending it with several conditional statements (wp_get_attachment_image_src and more) in the WP Loop, as well as setting several (add_image_)sizes, we managed to pull it off. It is a very complex WP Loop with tons of echos but it meet our goal of using featured image size to decide on what layout to present to the visitor.

1 Answer 1


The problem there is that the WP uploader will automatically resize any image you upload to all your specified image sizes, providing the original is larger than the specified size.

Relying on uploading an image between two specific sizes is a very flimsy mechanism for dictating layout. What is actually different about the content of these posts - can they be categorized differently? Can you add a custom field that you can test for in your template and use that to control the layout?

  • I have no trouble sorting the issue with how WP handle image uploads. The posts share the same category and can not be separated. It has to boil down to being able to have two different classes for layout, based upon the width of the featured image (post thumbnail) Feb 20, 2012 at 11:39

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.