functions - Can You Set A Minimum Image Dimension For Resizing Images?

This seems like a simple request but I can't find how to do it anywhere.Using add_image_size you can designate maxi

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?

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?

Share Improve this question asked Oct 10, 2019 at 19:59 TnaceTnace 173 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745091071a4610697.html

相关推荐

  • functions - Can You Set A Minimum Image Dimension For Resizing Images?

    This seems like a simple request but I can't find how to do it anywhere.Using add_image_size you can designate maxi

    20小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信