Upload: Fix inaccurate HEIC/HEIF MIME type mapping#11920
Conversation
|
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. |
Summary
Fixes inaccurate HEIC/HEIF MIME type mappings. Previously, all HEIF-family uploads (
.heif,.heics,.heifs) were incorrectly mapped to and renamed as.heicbecause the$mime_to_extarray collapsed all variants into theheicextension.Additionally, this PR fixes two related issues:
.heicsand.heifswere missing from thewp_ext2type()image array, causing them not to be recognized as images in the Media Library.image/heicHEIF variants because of a hardcoded mime type check.Changes
src/wp-includes/functions.php$mime_to_extarray inwp_check_filetype_and_ext()to map each HEIF MIME type to its proper, distinct extension:image/heif→heifimage/heic-sequence→heicsimage/heif-sequence→heifs'heic'to the$heic_images_extensionstrigger array.'heics'and'heifs'to the image types array inwp_get_ext_types()..heic.src/wp-admin/includes/image.php'image/heic' === $mime_typecheck inwp_generate_attachment_metadata()with a call towp_is_heic_image_mime_type(). This ensures all HEIF variants (not justimage/heic) correctly trigger sub-size generation.Testing
.heicfile.heic, sub-sizes generated correctly.heiffile.heif, sub-sizes generated correctlyTrac ticket: https://core.trac.wordpress.org/ticket/65297
Use of AI Tools
AI assistance: No