I have code that looks like this:
$post_thumbnail = the_post_thumbnail( array ( $w, $h ) );
I want to know what I’m doing wrong. When I pass in values for width and height, WordPress returns an image with the correct hight but with the incorrect width. Is it possible for me to get the exact image specified?
Always start with the Codex. According to the function reference for
the_post_thumbnail()
:You need to create your custom image size, via
add_image_size( $name, $w, $h, $crop )
, and then callthe_post_thumbnail( $name )
.