• Resolved j0sh1e

    (@j0sh1e)


    I want display the featured image of a WordPress article in a container that is 460px wide and as long as it needs to be to fit the image in the correct aspect ratio.

    I was thinking that if I had the width ($w) and the height ($h) that I could do:

    ($w/460) * ($h) = $x

    and then call the featured image to be that size, since it doesn’t automatically maintain aspect ratio:

    the_post_thumbnail(array(460,$x));

    but my issue is that I do not know how to get the original size of the featured image because the file is never available in the PHP and only onced it’s rendered down to HTML by the CMS.

    Does anyone know how to get the dimensions of the featured image in the code? Or does anyone know how to maintain aspect ratio of a featured image if I only have the width value?

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

    (@j0sh1e)

    I added a class called featured-image that had a width of 460px and height set to inherit.

    <?php the_post_thumbnail( null,array('class' => 'featured-image')); ?>

Viewing 1 replies (of 1 total)
  • The topic ‘How to get dimensions of Post Thumbnail’ is closed to new replies.