Closed kennithnichol closed 4 years ago
Thanks @kennithnichol ! Let me take a look at this at length and get back to you!
Hey @kennithnichol apologies for the super late response!
I've taken a look at this, and I think that we shouldn't encourage users to define width or height to be 0, as mentioned here:
https://developer.wordpress.org/reference/functions/add_image_size/
Although height and width are not required parameters, their default values (0) will lead to unwanted behavior, so bear in mind that you should always define them. As mentioned before, use a value of 9999 to define the other dimension as the one to be considered when image resize is executed.
So if users want to maintain the aspect ratio for an image, they could use a high number like 9999
as one of the sizes, rather than 0
.
I'm gonna close this issue, but please feel free to continue the discussion here!
WordPress permits passing 0 in for width or height to preserve the aspect ratio of the newly resized image.
The logic present in the add_image_size function retuns false because 0 is a falsey value in PHP.
The change will still prevent image sizes from being registered where both height and width are === 0.
Checklist:
ref issue #32