1

Why is hard cropping for the blog-grid-evensize not working?

When uploading an original that is 667x596, the blog-grid-odd and blog-grid-featured sizes are correctly cropped from the left top edge. But the blog-grid-even size is resized from the original 667x596 size, not cropped.

I've tried this without using the add_action(after_setup_theme..., force regenerated thumbnails many times, deleted all images and started over, etc., with no luck. This is not a GD library issue; the other image sizes are being cropped.

I've tried add_image_size( 'blog-grid-even', 323, 301, true); and nothing changes for that size. I can change the crop parameters for the other sizes, and they change after I force regenerate thumbnails.

This is not an image display issue on the front end; the blog-grid-even image in /uploads/ is being resized,not cropped.

function wpse_setup_theme() {
   add_theme_support( 'post-thumbnails' );
add_image_size( 'blog-grid-odd', 323, 596,array( 'left', 'top' ) );
add_image_size( 'blog-grid-even', 323, 301, array( 'left', 'top' ) );
add_image_size( 'blog-grid-featured', 667, 347, array( 'left', 'top' ) ); 
}

add_action( 'after_setup_theme', 'wpse_setup_theme' );

Original:

enter image description here

667, 347:

enter image description here

323, 596

enter image description here

323, 301

enter image description here

  • Are you really sure it is not cropped? Note that the aspect ratio of 667x596 and 323x301 are very similar, both are close to 1.1. Try with a original image with a very different aspecto ratio and check it. – cybmeta Dec 21 '16 at 17:15
  • Interesting; that's correct. I tried with a larger image than 667x596 and one with a different ratio and WP did crop. So this is wierdness with WP, I guess. Rather than reallly cropping when aspect rations are close, it resizes the entire image. – BlueDogRanch Dec 21 '16 at 17:45
  • I don't know the exact maths behind WordPress image manipulation, but I think it is not something weirdness. I just thinkg It is very difficult for a human eye to apreciate difference between aspect ratio of 1.11 (667x596) and 1.07 (323x301). – cybmeta Dec 21 '16 at 17:52
  • But I asking WP to hard crop left and top, and it doesn't; it resizes the entire image. Added the images above. – BlueDogRanch Dec 21 '16 at 18:07
  • I fully understand what you mean, but It is the expected behaviour. First, image is resized to the specified dimensions until either width or height is met; then it is cropped. Note how all images are first resized and then cropped, but 667x347 and 323x596 versions already have the specified width or height because it is the same than the original, so they are just cropped. – cybmeta Dec 21 '16 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.