Media: Update post mime type when image format is converted during upload#11261
Media: Update post mime type when image format is converted during upload#11261adamsilverstein wants to merge 1 commit intoWordPress:trunkfrom
Conversation
…load. When uploading HEIC files via the media library on servers that support HEIC, the image is correctly converted to JPEG on disk but the attachment post's `post_mime_type` remained `image/heic`. This updates `_wp_image_meta_replace_original()` to also update the post mime type when the saved image format differs from the original. Additionally fixes the REST API index to use `wp_get_image_editor_output_format()` so the `image_output_formats` response includes the default HEIC-to-JPEG mapping, enabling client-side media processing to be aware of it. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Trac Ticket MissingThis pull request is missing a link to a Trac ticket. For a contribution to be considered, there must be a corresponding ticket in Trac. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in the Core Handbook. |
|
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
_wp_image_meta_replace_original()to also update the attachment'spost_mime_typewhen the image is converted to a different format (e.g., HEIC to JPEG). Previously, the actual files on disk were correctly converted but the post's mime type remained unchanged.wp_get_image_editor_output_format()when buildingimage_output_formats, so the default HEIC-to-JPEG mapping is properly exposed to client-side media processing.Trac ticket
https://core.trac.wordpress.org/ticket/XXXXX (to be created)
Test plan
image/jpegafter upload, notimage/heic/wp-json/) includesimage/heic: image/jpeginimage_output_formatswhen client-side media processing is enabled🤖 Generated with Claude Code