-
Notifications
You must be signed in to change notification settings - Fork 130
Allow control for which image sizes to generate additional MIME type versions #415
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
Allow control for which image sizes to generate additional MIME type versions #415
Conversation
… not allowed to have additional mime types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eugene-manuilov Looks good, just added a comment following on from @peterwilsoncc review
…w-control-for-which-sizes-to-generate-webp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eugene-manuilov This mostly looks solid. I have some thoughts on the data format chosen here which is overly complicated IMO. It makes sense to be able to use isset
over array_search
, but we should not make such very "minor" performance enhancements at the cost of developer experience (the duplication of data there right now is problematic to me). We can probably find a way to do it in a way that is both performant and more clear for developers.
modules/images/webp-uploads/load.php
Outdated
); | ||
|
||
foreach ( $additional_sizes as $size => $size_details ) { | ||
if ( ! empty( $size_details['provide_additional_mime_types'] ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does provide_additional_mime_types
property come from or this something you were thinking we would add later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be the field that can later be populated via add_image_size
's additional parameter. So having this here prepares us for that.
Technically, one could already set it now by directly touching the $_wp_additional_image_sizes
global - which of course is discouraged, but I think it makes sense supporting this here already since we'll need it anyway and it's technically possible.
…w-control-for-which-sizes-to-generate-webp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eugene-manuilov Production code looks good, however we should remove all the additional sizes again. The remaining feedback is exclusively some minor things about tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eugene-manuilov Looks great, thank you!
@adamsilverstein @peterwilsoncc Can you please give this a pass too? We need at least a second approval :) |
add_image_size( 'allowed_size_400x300', 400, 300, true ); | ||
add_image_size( 'not_allowed_size_200x150', 200, 150, true ); | ||
|
||
$GLOBALS['_wp_additional_image_sizes']['allowed_size_400x300']['provide_additional_mime_types'] = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this could be removed once we update add_image_size
to accept the new "output_additional_mimes" parameter, right? Can you add a TODO comment to remove this once that is in place?
+1 looks good to me, I left one request to comment on the |
@adamsilverstein Added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent!
FYI: WordPress/wordpress-develop#3166 is the new PR that implements a slightly modified version of this for WordPress core. |
Summary
Fixes #413
Relevant technical choices
Checklist
[Focus]
orInfrastructure
label.[Type]
label.no milestone
label.