close
The Wayback Machine - https://web.archive.org/web/20220720233235/https://github.com/WordPress/performance/pull/143
Skip to content
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

Ensure the -scaled image remains in the original uploaded format #143

Merged
merged 8 commits into from Feb 7, 2022

Conversation

adamsilverstein
Copy link
Member

@adamsilverstein adamsilverstein commented Feb 1, 2022

Summary

When uploading very large images (over the big_image_size_threshold filter threshold), WordPress creates a scaled version of the image with the word-scaled appended to the file name. It stores a reference to the original image in the image meta original_image field, see this make post for more details.

WordPress subsequently uses the "scaled" image as if it were the original in most use cases (only going back to the true original image when editing the image). This causes the mime type shown in the media library for a large jpeg upload to show as image/webp because the scaled image is a WebP.

To fix that, in this PR I skip the -scaled image, leaving it in the original format of the uploaded image.

This matches the behavior of uploading a smaller image that isn't over the big_image_size_threshold, improving consistency.

Fixes #67

Relevant technical choices

  • Makes sense that the scaled image, which WordPress largely treats as the "original" would remain in the mime type of the upload
  • Ensure the behavior is consistent between large and smaller image uploads.

Checklist

  • PR has either [Focus] or Infrastructure label.
  • PR has a [Type] label.
  • PR has a milestone or the no milestone label.

@adamsilverstein adamsilverstein requested a review from getsource as a code owner Feb 1, 2022
@adamsilverstein adamsilverstein added [Focus] Images [Module] WebP Uploads [Type] Bug Needs Review labels Feb 1, 2022
@adamsilverstein adamsilverstein added this to the 1.0.0-beta.1 milestone Feb 1, 2022
Copy link
Member

@felixarntz felixarntz left a comment

Looks good, just two comments.

modules/images/webp-uploads/load.php Show resolved Hide resolved
modules/images/webp-uploads/load.php Outdated Show resolved Hide resolved
modules/images/webp-uploads/load.php Outdated Show resolved Hide resolved
@mitogh
Copy link
Member

@mitogh mitogh commented Feb 2, 2022

Additionally if we are going with this route once this is merged we should be able to close:

adamsilverstein and others added 2 commits Feb 2, 2022
Co-authored-by: Crisoforo Gaspar Hernández <hello@crisoforo.com>
@adamsilverstein
Copy link
Member Author

@adamsilverstein adamsilverstein commented Feb 2, 2022

Additionally if we are going with this route once this is merged we should be able to close:

Thinking we should generate both, see #142 (comment)

@adamsilverstein adamsilverstein requested a review from audrasjb as a code owner Feb 2, 2022
@adamsilverstein adamsilverstein requested a review from felixarntz Feb 2, 2022
@adamsilverstein adamsilverstein merged commit e0f2cd5 into trunk Feb 7, 2022
5 checks passed
@adamsilverstein adamsilverstein deleted the fix/skip-scaled-transform branch Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Images [Module] WebP Uploads Needs Review [Type] Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants