Opened 4 weeks ago
Last modified 3 weeks ago
#62365 new enhancement
HEIC upload conversion mappings may conflict with `image_editor_output_format` overrides
Reported by: | ironprogrammer | Owned by: | |
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | 6.7 |
Component: | Media | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
In testing #62359, I checked whether overriding the generated image type would be supported when the original upload is HEIC. Using the sample code from 6.5's AVIF support post, I felt it reasonable to expect a HEIC upload to result in AVIF files, but that was not the case.
This is due to the resulting output from the filter, which includes new default HEIC->JPEG mappings in 6.7. E.g. after applying the test filter, the output formats are:
{ ["image/heic"]=> string(10) "image/jpeg" ["image/heif"]=> string(10) "image/jpeg" ["image/heic-sequence"]=> string(10) "image/jpeg" ["image/heif-sequence"]=> string(10) "image/jpeg" ["image/jpeg"]=> string(10) "image/avif" }
Should WordPress reconcile the mappings for conversion before returning wp_get_image_editor_output_format()? Extenders (like in Modern Image Formats) could check this directly, but it seems WordPress should handle it for better consistency.
(I also want to note that a quick test of remapping each of the HEIC types to AVIF does result in alt-size generated files being .avif
. However, the original HEIC converted file remains JPEG if under the big image size threshold, so this goes deeper than the filter to achieve consistency. In the case of oversized images, they result in -scaled.avif
for the converted file, as expected.)
Change History (3)
#2
@
4 weeks ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 6.8
Good catch, would be nice to add it. Setting for 6.8.
Perhaps there is a chance this may be needed earlier to account for existing conversion settings added from plugins. I.e. a plugin adding conversion from JPEG to WEBP would not just add a setting for the image/jpeg
mime type, but for all supported formats (overriding the defaults in core):
array( 'image/heic' => 'image/webp', 'image/heif' => 'image/webp', 'image/heic-sequence' => 'image/webp', 'image/heif-sequence' => 'image/webp', 'image/jpeg' => 'image/webp', );
May be a good idea to add this to the introductory post, or even publish a follow-up dev. note?
This ticket was mentioned in PR #7815 on WordPress/wordpress-develop by @sukhendu2002.
3 weeks ago
#3
- Keywords has-patch has-unit-tests added; needs-patch removed
Trac ticket: https://core.trac.wordpress.org/ticket/62365
This PR addresses ticket #62365 by implementing proper support for chained image format conversions when handling HEIC uploads.
@ironprogrammer I've moved this to an enhancement as I think it would be a nicety rather than essential.
My instinct is that it's best left for plugins to resolve to allow maximum flexibility and to avoid making assumptions. It's certainly worth discussing though as my instinct could be incorrect.