0

I would like to crop in particular dimensions but I need that to be done on both height and width of the image. Here is a small illustration of what I am trying to do:

enter image description here

When I try to use this snippet:

add_image_size( 'custom-thumbnail', 160, 160, true);

or even

add_image_size( 'custom-thumbnail', 160, 160, array( 'center', 'center' ));

it only crops the horizontal side and so this is what I get:

enter image description here

And this is what needs to be achieved:

enter image description here

Is there any way to do that in WordPress? I made a lot of searches on Google but without success.

Thank you in advance for your help.

2
  • 1
    add_image_size() doesn't support this kind of cropping. Someone may answer with a solution but I just wanted to make that clear up front. Commented May 12, 2022 at 16:59
  • The workaround I'm using right now is to crop the image by 280x280px, then crop the image with CSS (set the size then overflow: hidden;), but then the weight of each thumbnail is higher. I would really like to find a more elegant solution :p
    – dragoweb
    Commented May 13, 2022 at 7:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.