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 badges1 Answer
Reset to default 0This 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
评论列表(0条)