I have an image which should be output on the page. The space is limited (width-max = 209px). Now I have to provide the image in a scaled size, if the user doesn't do it.
This is my code:
$src = wp_get_attachment_image_src($logo, 'full'); $width = $src; $height = $src; $new_width = 200; $factor = $width/$new_width; $new_height = round($height/$factor); echo wp_get_attachment_image($logo, array($new_width, $new_height))
But the image used is the thumbnail image (150x150) and the width and height in the html code is 92!
<img width="92" height="92" title="my title" alt="Logo" class="attachment-200x92" src="http://www.test.com/wp-content/uploads/2012/07/logo-150x150.jpg">
In the docu it is stated that I should use
add image size but the height can be different for each picture. Also what happens with already uploaded pictures?
How can I fix this?
add_image_size( 'squeeze', 200, 1000, false ); and Regenerate Thumbnails did the job for me.