Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm developing a theme and while working on the featured images area I've noticed they aren't cropping even though I've set them to crop through set_post_thumbnail_size function.

/* Featured Image Thumbnails */
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 460, 250, true);

Using xampp, phpinfo says GD is supported. I've cleared the thumbnails and regenerated them to no avail. The div that the featured image is in is also set to 460, 250. The image just scales down to 460 wide by whatever heigh and constrains its proportions.

An imag showing the output: http://i.imgur.com/cDXkS49.png

share|improve this question
    
Fixed the issue. For reference: /* Featured Image Thumbnails */ add_theme_support( 'post-thumbnails' ); //set_post_thumbnail_size( 460, 250, true); add_image_size( 'my-size', 460, 250, true ); And in the area where I call to display a featured image I added: <?php the_post_thumbnail('my-size'); ?> –  Dave W Mar 20 '13 at 16:26
    
You shouldn't have to do that. Using set_post_thumbnail_size() should set post-thumbnail to your desired dimensions, and then the_post_thumbnail() should use post-thumbnail as it's default size, if none is passed. –  David Gard Mar 20 '13 at 16:33

1 Answer 1

I may be misunderstanding you, but it seems that it is because your image is not 250px high in the first place. What is the original image dimension?

It's not really described well in the Function Reference, but 460 will the maximum width that an image can be, and 250 will be the maximum height. crop = true simply means that if either of those dimensions are bigger, the image will be cropped to fit, as opposed to resized.

For example, take an image that is 690px by 500px -

/**
 * This example will crop the image to just 460x250, therefore cutting off
 * the excess pixels
 */
set_post_thumbnail_size(460, 250, true);

/**
 * This example will resize the image to 345x250, so that it fits your desired
 * dimensions while at the same time keeping the whole image
 */
set_post_thumbnail_size(460, 250);
share|improve this answer
    
I was an image that was 1000px by 1000px and I wanted it to crop excess pixels outside of 460x250. I reworked how the call to setting the image size was done and we're good now. /* Featured Image Thumbnails */ add_theme_support( 'post-thumbnails' ); //set_post_thumbnail_size( 460, 250, true); add_image_size( 'my-size', 460, 250, true );the_post_thumbnail('my-size'); –  Dave W Mar 20 '13 at 16:33
    
Hmm, your original attempt should have worked. I'll do some testing, there may be an issue with set_post_thumbnail_size() ignoring the crop flag. –  David Gard Mar 20 '13 at 16:36
    
I couldn't find it, if you do please update! Appreciate the investigation. –  Dave W Mar 20 '13 at 16:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.