Auto convert HEIC images to JPEG on upload#7035
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. |
|
Code looks good imho. Wondering if it may be good to inform the user that an image they uploaded was converted? Or perhaps treat the conversions as "standard behavior" and inform them when it fails? Perhaps in the second case WP can advise them to convert it to JPEG and upload it again? Also, by default WP attempts to keep uploaded images as-is and treat them as "backups". Wondering if this behavior should continue when converting .heic/.heif images too? |
Yeah this is what the alternative solution #7034 does. I prefer it. Will close this PR. |
Automatically converts HEIC images to JPEG on upload. See ticket for details and motivation.
Implementation is based on the GPL2 HEIC Support plugin written by @csalzano. Attribution is included in the doc comment.
Unlike the HEIC Support plugin, HEIC images are always converted to JPEG and the original file is deleted. This is what the majority of users will want and aligns with what Apple does in its apps that support HEIC. Website admins can customise the behaviour by installing a plugin (e.g. HEIC Support) or by removing the hook:
The existing error message that appears when you upload a HEIC image that encourages the user to convert the image and try again is suppressed when auto-conversion is enabled.
Here's a video showing how this looks:
Kapture.2024-07-16.at.11.51.20.mp4
You'll note in the video that the Image block doesn't look great while the HEIC is uploading. This is because I'm using a browser that doesn't support HEIC and so the Image block isn't able to show a preview. We'll need to improve this in Gutenberg as a separate PR by e.g. showing a nicer placeholder when there is no image available.
Trac ticket: https://core.trac.wordpress.org/ticket/53645