New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use image_resize_dimensions to correctly downsize image styles #22

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@underdude
Copy link

underdude commented Feb 26, 2015

Image styles are about fitting the image in its original aspect ratio into the boundaries of current image style. So instead of using the image style size to determine which argument we should pass to getImageServingUrl, we should calculate the dimensions for the final image and find the argument from those values. Because of the possible differences in aspect ratios between the image style and the actual image, the resizing argument can be something else than either of the image style constraints.

We can use the same core function (image_resize_dimensions) that WordPress uses internally to determine these final image dimensions. The function also helps us to determine if current image style is not intermediate for the image and leave those options off as WordPress itself does.

The latest fix by tuanmh (#21) addresses the problem with captions (WordPress for some reason requires the pixel dimensions to be present for captions), but uses the image style size instead of the final image size which results in distorted images if the aspect ratios don't match.

Image styles are about fitting the image in its original aspect ratio…
… into the boundaries of current image style. So instead of using the image style size to determine which argument we should pass to getImageServingUrl, we should calculate the dimensions for the final image and find the argument from those values. Because of the possible differences in aspect ratios between the image style and the actual image, the resizing argument can be something else than either of the image style constraints.

We can use the same core function (image_resize_dimensions) that WordPress uses internally to determine these final image dimensions. The function also helps us to determine if current image style is not intermediate for the image and leave those options off as WordPress itself does.

The latest fix by tuanmh (#21) addresses the problem with captions (WordPress for some reason requires the pixel dimensions to be present for captions), but uses the image style size instead of the final image size which results in distorted images if the aspect ratios don't match.
@tmatsuo

This comment has been minimized.

Copy link
Member

tmatsuo commented Mar 5, 2017

@underdude
Thanks for the contribution. However we won't update the App Engine plugin anymore unless there's a serious security issue. Eventually we will recommend gcs plugin over this one.

@tmatsuo tmatsuo closed this Mar 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment