0

This seems like a simple request but I can't find how to do it anywhere.

Using add_image_size you can designate maximum width and/or height for an image to be cropped or rescaled but I can't find how to set a minimum width and/or height.

For example, if you have a 2,000px by 1,000px image the code below will resize the image to 600px by 300px image.

add_image_size('gallery-image', 600, 600);

However, what I'm looking for is to set the MINIMUM dimension on an image to be a certain number of pixels. Thus, code that would resize a 2,000px by 1,000px image to 1,200px by 600px.

Does anyone know how to do this?

1 Answer 1

0

This could be a dumb idea, but what if you set it to

add_image_size('gallery-image', 9999, 600);

As long as you don't add 'true' it won't crop, it scales to fit into the space by default. It would then try to fit into the smaller of the two, the height in this case, and scale down appropriately. Or you could do the width as the constraint and make the height the ridiculously large one.

1
  • I think what the OP is looking for is both - so for a 2000x1000 image or a 1000x2000 to be resized to 1200x600 or 600x1200 respectively. Commented Mar 1, 2020 at 11:46

Your Answer

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

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