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.

Steps to reproduce...

1) Add to functions.php:

add_image_size( 'half-size', 200, 200, false );

2) Add to template file (inside loop):

<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >

 <?php the_post_thumbnail ('half-size', array('class' => 'profile_image')); ?> </a>

3) Go to media library and add image to post gallery. Then crop image, click "thumbnail" radio button and click save underneath the image.

4) Click set as featured image then "save all changes" at the bottom of the gallery dialog window. Then update the post (may not be necessary).

Do not insert into gallery. Click over to the actual post and see if it is showing the part of the image you cropped or the whole image.

What am I doing wrong? Or does cropping inexplicably not work with Featured Image?

Apparently, there is no ticket out for this issue.

share|improve this question
1  
I'm not sure if it's the same issue, but I did read on the trac there was an issue when using an image that was the exact size as a preset. I'm just curious why are you cropping the images to the exact size, then setting them as a custom dimension? If you are using the exact size you are cropping to, you could just use the_post_thumbnail( 'thumbnail' ); –  Jeremy Jared Aug 24 '11 at 5:57
    
Because the auto crop doesn't always crop a centered part of the image. I'm dealing with a lot of images that sometimes have a main photo on one side, blank space in the middle and text on the other side. –  Adam Aug 24 '11 at 12:09
    
Oh I think I see what you mean now. Answering question :) –  Adam Aug 24 '11 at 12:44
add comment

2 Answers 2

I was confusing add_image_size with set_post_thumbnail_size. The problem with the latter is that you can only set one 'thumbnail' size.

I wanted to be able to keep the original image intact and apply a custom crop to the thumbnail version of the image. I'm using multiple image sizes around the site as the 'thumbnail' though.

So the fix here is to change 'half-size' to 'thumbnail' wherever I want to display the cropped image. It's a good idea to set 'thumbnail' as the largest image you will use it as. Because you will have to use CSS classes to resize it down to the other image size.

There could be some negative drawbacks to this though like when inputting a 'gallery' now, I'm likely to get the larger thumbnail image size instead of the standard I had set before.

share|improve this answer
add comment

The reason that half-size isn't cropping is because you've specified for it not to hard-crop:

add_image_size( 'half-size', 200, 200, false );

That final parameter, which is defined as false, is the hard-crop parameter:

  • Set to true to hard-crop
  • Set to false to box-resize

If you need the half-size image to crop, change that parameter:

add_image_size( 'half-size', 200, 200, true );
share|improve this answer
    
That did not work for me. Still showing original image. Unless I have to re-crop after making the change? –  Adam Aug 24 '11 at 13:20
2  
@Adam It will work just regenerate your thumbnails, use this plugin wordpress.org/extend/plugins/regenerate-thumbnails –  Mamaduka Aug 24 '11 at 13:26
    
@Mamaduka is correct. If you make changes to image sizes, then you will have to regenerate thumbnails for existing images in order to see those changes apply. –  Chip Bennett Aug 24 '11 at 13:40
    
Installed Regenerate Thumbnails. Removed featured image from post. Re-cropped to dimensions both over 200x200 & under 200x200 (just in case). Applied changes only to thumbnail (remember, I want original in tact). Saved crop. Clicked "Use as featured image." Saved all changes. Went to post page and still showing me the original image (yes, it's sized down to the correct max dimension, but it's not cropped). –  Adam Aug 24 '11 at 14:21
    
This is Twenty Eleven, fairly new install. Only a handful of plugins, none being gallery plugins, so I don't see why this shouldn't be working. –  Adam Aug 24 '11 at 14:22
show 2 more comments

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.