I'm trying to figure how to scale the_post_thumbnail to a specific width? Can you guys help?
Currently I'm using
<?php
//Resize post thumbnail
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' );
$thumbnailHeight = $thumbnail[1];
$thumbnailWidth = $thumbnail[2];
if($thumbnailHeight != 0){
$ratio = $thumbnailWidth/$thumbnailHeight;
$width = 220;
$height = $width * $ratio;
}else{
$height = $thumbnailHeight;
$width = $thumbnailWidth;
}
?>
And printing the thumbnail with
<img src="<?php echo $thumbnail[0]; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>"/>
It works but....
Thanks!