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.
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.
The reason that
half-size
isn’t cropping is because you’ve specified for it not to hard-crop:That final parameter, which is defined as
false
, is the hard-crop parameter:true
to hard-cropfalse
to box-resizeIf you need the
half-size
image to crop, change that parameter: