• Resolved dogoodzilla

    (@dogoodzilla)


    How to use the featured image´s width in an if statement to set layout class for a single post?

    I have been experimenting with has_post_thumbnail and also read about how to check image width using wp_get_attachment_image_src. With more than 100 tabs open and 7 hours of testing I am writing here..

    My Setup
    I upload very large (in pixles) images and use them as featured images. I use Simple Image Size to create a set of sizes that I use throughout the theme.

    For single posts I want to check the featured image width somehow and add a class to the one I am displaying.

Viewing 1 replies (of 1 total)
  • Thread Starter dogoodzilla

    (@dogoodzilla)

    Now I have something I think I can work with. Hopefully some of you fine individuals can enjoy this.

    I took the twentyten_header_image_width and modified the width ( in functions.php) to the maximum width of the thumb that I use.

    I then added the if statement from the header in the Twenty Ten theme and added it twice (I have two featured image sizes here).

    I changed the second statement a bit:
    $image[1] >= HEADER_IMAGE_WIDTH ) vs. $image[1] < HEADER_IMAGE_WIDTH )

Viewing 1 replies (of 1 total)
  • The topic ‘Display featured image based on width’ is closed to new replies.