set_post_thumbnail_size not cropping featured images, but reducing proportionally

In my function file, I set the following:

if ( function_exists( 'add_theme_support' ) ) {
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 150, 50, true );   
}

And in the loop:

<?php the_post_thumbnail();  ?>

But the images are resized proportionally, using the smallest value. The crop is not working.

UPDATE

I change the function:

function resize_thumb () {
   add_theme_support( 'post-thumbnails' );
   set_post_thumbnail_size( 280, 80, true );
}

add_action ( 'after_setup_theme', 'resize_thumb' );

But the desire crop not happens.

SOLVED

In functions.php, I add just this line:

add_image_size( 'thumbnail-news', '190', '40', true );

And in the loop I add this line

<?php the_post_thumbnail( 'thumbnail-news' ); ?>

To resize old images, I use Regenerate Thumbnails plugin.

1 Answer
1

Contrary to Pieter, I’d say your if statement is correct (although, unnecessary). If it’s a WordPress theme, then add_theme_support will likely exist!

Have you per chance added the images before setting the post thumbnail size? If so, you need to regenerate your images:

Regenerate Thumbnails

Leave a Comment