Opened 14 months ago
Last modified 3 months ago
#56288 accepted enhancement
Add mime output control to `add_image_size`
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description (last modified by )
Summary
- Add an option to the
add_image_size
function so that developers can control whether secondary mime types are generated for the image size they are adding.
Description
In #55443 we introduced multi-mime support and the capability to generate sub-sizes in secondary mime types (or even to replace the primary output mime). The code includes a filter that enables developer control over which sizes output secondary mimes. This ticket aims to extend that work by adding control over secondary mime generation per size at the point of registration.
Considerations
This proposal is to add a new $output_mimes
boolean parameter to the add_image_size
function. I also considered instead adding an $output_options
(keyed) array parameter, this would then have an option for output_mimes
and in the future we could use this to enable a quality setting per size which we have discussed elsewhere already.
I decided to keep this PR simple by using a boolean vs an array because that is all we need now. I would appreciate feedback on this approach in addition to the code here or on the PR.
Attachments (6)
Change History (28)
This ticket was mentioned in PR #3028 on WordPress/wordpress-develop by adamsilverstein.
14 months ago
#3
- Keywords has-unit-tests added
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
14 months ago
This ticket was mentioned in Slack in #core-media by adamsilverstein. View the logs.
14 months ago
adamsilverstein commented on PR #3028:
14 months ago
#7
@felixarntz Addressed your feedback here & ready for another review whenever you have a chance
adamsilverstein commented on PR #3028:
14 months ago
#9
@felixarntz updated based on your feedback, ready for another review
#10
@
13 months ago
56288.3.diff includes the latest updates from the PR
#11
@
13 months ago
- Keywords needs-dev-note commit added; dev-feedback removed
56288.4.diff includes the final changes from the PR
#12
@
13 months ago
56288.5.diff update against trunk
adamsilverstein commented on PR #3028:
13 months ago
#13
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 commented on PR #3028:
13 months ago
#14
I removed the doing_it_wrong
warning for now in `12986a3` (#3028) and will mention that on the Trac ticket as well.
#15
@
13 months ago
56288.6.diff removes the "doing_it_wrong" notice for now, see https://core.trac.wordpress.org/ticket/56288#comment:13
This ticket was mentioned in Slack in #core-media by adamsilverstein. View the logs.
13 months ago
felixarntz commented on PR #3028:
13 months ago
#18
@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()
.
#20
@
12 months ago
- Keywords needs-dev-note commit removed
- Milestone changed from 6.1 to Future Release
After reverting WebP in core for 6.1(r54226), @adamsilverstein and @flixos90 confirmed that this should move to Future Release
for continued work.
Trac ticket: https://core.trac.wordpress.org/ticket/56288