[wp-trac] [WordPress Trac] #62365: HEIC upload conversion mappings may conflict with `image_editor_output_format` overrides
WordPress Trac
noreply at wordpress.org
Wed Mar 19 20:13:17 UTC 2025
#62365: HEIC upload conversion mappings may conflict with
`image_editor_output_format` overrides
--------------------------------------------+------------------------------
Reporter: ironprogrammer | Owner: adamsilverstein
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.8
Component: Media | Version: 6.7
Severity: normal | Resolution:
Keywords: has-testing-info needs-refresh | Focuses:
--------------------------------------------+------------------------------
Changes (by SirLouen):
* keywords: has-patch has-unit-tests => has-testing-info needs-refresh
Comment:
== Test Report
=== Description
This report can't validate that the patch works as expected.
Patch tested: https://github.com/WordPress/wordpress-
develop/pull/7815.diff
=== Environment
- WordPress: 6.8-alpha-59274-src
- PHP: 8.2.28
- Server: nginx/1.27.4
- Database: mysqli (Server: 8.4.4 / Client: mysqlnd 8.2.28)
- Browser: Chrome 134.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-Five 1.0
- MU Plugins: None activated
- Plugins:
* Test Reports 1.2.0
=== Expected Results
- The expected results is uploading a HEIC image and having all images
converted to AVIF in multiple sizes
=== Testing Procedure
1. Add this snippet to functions.php a plugin, or wherever it can be
loaded
{{{#!php
function filter_image_editor_output_format( $formats ) {
$formats['image/heic'] = 'image/avif';
return $formats;
}
add_filter( 'image_editor_output_format',
'filter_image_editor_output_format' );
}}}
2. Upload an image in HEIC format. Example: https://heic.digital/download-
sample/classic-car.heic
3. Go to the uploads directory and check for all the converted images.
=== Actual Results
==== Without patch
- Images are converted to JPG instead of AVIF as expected, as this is the
default behaviour
{{{
root at bb89abdaa4e7:/var/www/src/wp-content/uploads/2025/03# ls classic-car*
classic-car-1152x1536.jpg classic-car-1536x2048.jpg classic-car-
768x1024.jpg classic-car.heic
classic-car-150x150.jpg classic-car-225x300.jpg classic-car-
scaled.jpg
}}}
==== With patch
- ❌ The patch is not fully working as expected
- Some images are converted to AVIF, but not all
- The conversion takes too long: https://i.imgur.com/qRHZaCr.png
- And after a while it fails: https://i.imgur.com/oTNp8VR.png
In the end, not all image sizes are generated + one is corrupted:
{{{
root at bb89abdaa4e7:/var/www/src/wp-content/uploads/2025/03# ls classic-car*
classic-car-1152x1536.avif classic-car-225x300.avif classic-car-
scaled.avif
classic-car-150x150.avif classic-car-768x1024.avif classic-car.heic
root at bb89abdaa4e7:/var/www/src/wp-content/uploads/2025/03# file --mime-
type classic-car.heic
classic-car.heic: image/heic
root at bb89abdaa4e7:/var/www/src/wp-content/uploads/2025/03# file --mime-
type classic-car-scaled.avif
classic-car-scaled.avif: application/octet-stream
root at bb89abdaa4e7:/var/www/src/wp-content/uploads/2025/03# file --mime-
type classic-car-150x150.avif
classic-car-150x150.avif: application/octet-stream
root at bb89abdaa4e7:/var/www/src/wp-content/uploads/2025/03# file --mime-
type classic-car-225x300.avif
classic-car-225x300.avif: application/octet-stream
root at bb89abdaa4e7:/var/www/src/wp-content/uploads/2025/03# file --mime-
type classic-car-768x1024.avif
classic-car-768x1024.avif: application/octet-stream
root at bb89abdaa4e7:/var/www/src/wp-content/uploads/2025/03# file --mime-
type classic-car-1152x1536.avif
classic-car-1152x1536.avif: inode/x-empty (CORRUPTED IMAGE)
}}}
I'm testing with regular parameters from the `wordpress-develop` docker.
Maybe increasing the PHP execution time could lead to a full conversion.
Anyway, I'm not sure if taking that long is worth the deal, maybe this is
because of the chained conversions? This leads to further discussion.
=== Additional Notes and Further Discussion
- I'm not completely aware of how the conversion is being done behind the
scene. Judging from the conversation, it seems that there is a double
conversion in a chain: First from HEIC to JPG (default) and then from JPG
to AVIF (with thanks to the filter hook upgrade).
- Still, I'm not if it's possible to do a straight conversion from HEIC to
AVIF. The suggestion is that this type of conversion should be left to
plugins, not native to WP.
- I'm assuming that @adamsilverstein suggests leaving open this ticket
just in case someone takes the time to upgrade the conversion system to
avoid a chained conversion?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62365#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list