I want my thumbnails on a particular page to be 300px
× 100px
, exactly. Currently, images shrink until they hit the 300 pixel or 100 pixel mark. How do I get the image to crop to exactly 300 × 100 (preferably without image distortion).
// functions.php:
if ( function_exists( 'add_image_size' ) ) add_theme_support( 'post-thumbnails' );
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'post-thumb', 620, 207, true );
add_image_size( 'home-thumb', 220, 180, true );
add_image_size( 'index-thumb', 300, 100, true );
}
// index.php:
if ( has_post_thumbnail()) the_post_thumbnail('index-thumb');
Refer to the
add_image_size()
Codex entry:The
$crop
parameter is the key:That is:
Thus your code should work:
If you find that your images are not being rendered/displayed properly, there are a couple of things to verify:
Take a look to this plugin
Try to Change the “ture” paramater to “false” .
You can also remove the “if” statements on the functions php if they are not needed for something else…