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

[WIP] Generate additional mime types on upload #151

Closed
wants to merge 14 commits into from

Conversation

adamsilverstein
Copy link
Member

Summary

  • Add a new filter image_editor_output_formats that returns the output formats and their order. The first type is used as the default output format
  • The default image_editor_output_format filter applies for the first mime type, which also creates a full sized image if not the dame mime type as the uploaded image.
  • New sub sizes and a full sized image are created for each mime type in the returned array

Usage

By default, this code will generate WebP and jpeg sub sizes for every uploaded image, with WebP as the default.

  • Adding add_filter( 'image_editor_output_formats', '__return_false' ); would ensure only the uploaded mime type would be use for sub sizes (current WordPress behavior).
  • Adding add_filter( 'image_editor_output_formats', function() { return array( 'image/jpeg', 'image/webp' ); } ); would ensure jpeg and WebP were generated, with jpeg stored in sizes and used as the default output format
  • Adding add_filter( 'image_editor_output_formats', function() { return array( 'image/webp' ); } ); would ensure only WebP sub sizes were generated (current behavior of the webp-uploads module).

Fixes #

Relevant technical choices

Checklist

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

@adamsilverstein adamsilverstein added this to the 1.0.0-beta.1 milestone Feb 4, 2022
@adamsilverstein adamsilverstein added [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Enhancement A suggestion for improvement of an existing feature labels Feb 4, 2022
@felixarntz
Copy link
Member

@adamsilverstein We need to be careful here to not introduce this logic entirely on the server-side, to avoid timeouts. This relates to the enhancements from https://core.trac.wordpress.org/ticket/40439 - the additional sizes in the other format have to somehow be kicked off from the client-side, so that the server can take care of them through individual requests.

@felixarntz
Copy link
Member

@adamsilverstein Do we still need this PR to be open? I'm thinking it's probably somewhat of a duplicate of #147 which is being worked on now.

@adamsilverstein
Copy link
Member Author

Closing, this was an experimental PR.

@felixarntz felixarntz added the no milestone PRs that do not have a defined milestone for release label Mar 7, 2022
@felixarntz felixarntz removed this from the 1.0.0-beta.1 milestone Mar 7, 2022
@tillkruss tillkruss deleted the add/additional-mime-types branch March 7, 2022 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no milestone PRs that do not have a defined milestone for release [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When uploading, generate both WebP and jpeg format images by default
2 participants