the_post_thumbnail scaling not hard cropping

Per the Codex entry for the_post_thumbnail(), passing an array has not worked since WordPress 3.0:

PLEASE NOTE: The crop does not work in WP 3.0+. All that is needed for WP 3.0+ is the call for the thumbnail to post. Then proceed to media in the dashboard and set your thumbnail to crop to the size you wish to use.

The correct implementation is to create a custom image size with your array values, via add_image_size() inside the Theme setup function (or any other callback hooked into after_setup_theme):

add_image_size( 'custom-size', 1024, 512, true );

…then call that size directly:

the_post_thumbnail( 'custom-size' );

Leave a Comment