Skip to content

Add a additional_mimes parameter to the add_image_size function - #3028

Closed
adamsilverstein wants to merge 26 commits into
WordPress:trunkfrom
adamsilverstein:add/add-image-size-mime-support
Closed

adamsilverstein wants to merge 26 commits into
WordPress:trunkfrom
adamsilverstein:add/add-image-size-mime-support

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented Jul 26, 2022 •

Copy link
Copy Markdown
Member

Trac ticket: https://core.trac.wordpress.org/ticket/56288

Related to: https://core.trac.wordpress.org/ticket/55443

Testing Instructions

Test in WordPress Playground


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@felixarntz felixarntz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamsilverstein This looks solid mostly. I left some feedback below.

Let's also add some test coverage, but I don't think it's worth updating all the other tests unnecessarily - the parameter is optional, so it seems pointless to set it in tests where it's not relevant.

Comment thread src/wp-includes/media.php Outdated
Comment thread src/wp-includes/media.php Outdated
Comment thread src/wp-includes/media.php Outdated
Comment thread src/wp-includes/media.php Outdated
Comment thread src/wp-includes/media.php
Comment thread tests/phpunit/tests/image/intermediateSize.php Outdated
Comment thread tests/phpunit/tests/media.php Outdated
Comment thread tests/phpunit/tests/media.php
@adamsilverstein

Copy link
Copy Markdown
Member Author

@felixarntz Addressed your feedback here & ready for another review whenever you have a chance

@felixarntz felixarntz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamsilverstein Mostly looks good to me. I left some minor feedback.

My main point is actually to focus on improving the parameter documentation. The special behavior we intend for this parameter should be clearly explained.

Comment thread src/wp-includes/media.php Outdated
Comment thread src/wp-includes/media.php Outdated
Comment thread src/wp-admin/includes/image.php Outdated
Comment thread src/wp-admin/includes/image.php Outdated
Comment thread tests/phpunit/tests/media.php Outdated
Comment thread tests/phpunit/tests/media.php Outdated
@adamsilverstein

Copy link
Copy Markdown
Member Author

@felixarntz updated based on your feedback, ready for another review

Avoid a “doing it wrong” message - “You should provide a value for the `additional_mimes` parameter.”
@adamsilverstein adamsilverstein changed the title Add a boolean ‘output_mimes’ parameter to the add_image_size function (and adjust all uses) Add a ‘additional_mimes’ parameter to the add_image_size function Aug 15, 2022
@adamsilverstein adamsilverstein changed the title Add a ‘additional_mimes’ parameter to the add_image_size function Add a additional_mimes parameter to the add_image_size function Aug 15, 2022

@felixarntz felixarntz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamsilverstein Just few final fixes to make here.

Comment thread src/wp-includes/media.php Outdated
Comment thread src/wp-includes/media.php Outdated
Comment thread src/wp-includes/media.php
adamsilverstein and others added 5 commits August 16, 2022 08:59
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
@adamsilverstein

Copy link
Copy Markdown
Member Author

Also: Do we want to trigger a _doing_it_wrong() if the parameter is not passed? Or should we hold off until later? Note that if we don't trigger a warning here now, it may delay the point in time when we can change the default.

Reconsidering this: the additional error logging might be excessive for anyone who has error logging enabled - any existing image sizes need to get updated or they will throw a warning... I feel we should give developers one release cycle (at least) before adding this notice. what do you think?

So my idea would be to add this in 6.1 with a Dev Note, but no warning. The in 6.2 we can add the doing_it_wrong notice; finally, in 6.3 we will switch the default from null to true.

@adamsilverstein

Copy link
Copy Markdown
Member Author

I removed the doing_it_wrong warning for now in 12986a3 (#3028) and will mention that on the Trac ticket as well.

@felixarntz

Copy link
Copy Markdown
Member

@adamsilverstein Now that https://core.trac.wordpress.org/changeset/54097 has been committed, I suggest we refresh this PR against latest trunk and then adjust.

Most of the code here is still relevant as is, we just need to change the integration point which now is no longer in _wp_filter_image_sizes_additional_mime_type_support() but in wp_default_image_output_mapping().

@mukeshpanchal27

Copy link
Copy Markdown
Member

@adamsilverstein Does this PR still remain relevant? If so, could you please update it and mark it as ready for review?

@adamsilverstein

Copy link
Copy Markdown
Member Author

Closing for now. Maybe later.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants