Media: Enable HEIC/HEIF uploads when server lacks image editor support#11323
Media: Enable HEIC/HEIF uploads when server lacks image editor support#11323adamsilverstein wants to merge 1 commit intoWordPress:trunkfrom
Conversation
Bypass the `wp_prevent_unsupported_mime_type_uploads` check for HEIC/HEIF images so they can be stored even when the server's image editor doesn't support them. The client-side canvas fallback handles processing using the browser's native HEVC decoder via createImageBitmap().
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Trac ticket: https://core.trac.wordpress.org/ticket/64915
What?
Allow HEIC/HEIF image uploads to succeed even when the server's image editor (ImageMagick/GD) doesn't support HEIC. Currently,
wp_prevent_unsupported_mime_type_uploadsblocks these uploads entirely.Gutenberg PR: WordPress/gutenberg#76731
Why?
HEIC is the default photo format on iPhones. When users upload HEIC images and the server can't process them, the upload fails with an unhelpful error. With the client-side media processing feature, the browser can decode HEIC using its native
createImageBitmap()API (leveraging OS-licensed HEVC codecs) and convert to JPEG for sub-size generation. But first, the server needs to accept the upload.How?
In
WP_REST_Attachments_Controller::create_item_permissions_check(), bypass the$prevent_unsupported_uploadscheck when the uploaded file is HEIC/HEIF (detected via the existingwp_is_heic_image_mime_type()helper). This allows the file to be stored on the server, after which the client-side canvas fallback generates a JPEG version and all required sub-sizes.Testing Instructions
rest_upload_image_type_not_supportederror)missing_image_sizesis populated in the response (server couldn't generate sub-sizes)