Skip to content

Media: Set HEIC upload support flag for canvas-based conversion#12561

Open
adamsilverstein wants to merge 2 commits into
WordPress:trunkfrom
adamsilverstein:fix/heic-upload-support-flag
Open

Media: Set HEIC upload support flag for canvas-based conversion#12561
adamsilverstein wants to merge 2 commits into
WordPress:trunkfrom
adamsilverstein:fix/heic-upload-support-flag

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

The block editor's HEIC canvas fallback is gated on window.__heicUploadSupport, but core never sets that flag. The Gutenberg plugin sets it via gutenberg_set_heic_upload_support_flag(), and core has no equivalent.

As a result, on a core-only WordPress 7.1 install, browsers that cannot use the full WebAssembly (vips) pipeline get no client-side HEIC conversion at all. This primarily affects Safari:

  1. Core only enables cross-origin isolation via Document-Isolation-Policy for Chromium 137+ (wp_set_up_cross_origin_isolation()), so in Safari detectClientSideMediaSupport() fails and the full vips pipeline is disabled.
  2. The editor then checks the HEIC-only canvas path (shouldEnableHeicCanvasProcessing() in @wordpress/block-editor), which requires window.__heicUploadSupport - never set by core - so it bails before even checking browser capability.

Safari is exactly the browser this fallback was built for: it can decode HEIC natively via createImageBitmap() and convert to JPEG on a canvas, without needing SharedArrayBuffer or cross-origin isolation.

Changes

  • Set window.__heicUploadSupport = true in wp_set_client_side_media_processing_flag(), alongside the existing __clientSideMediaProcessing flag. It respects the same wp_client_side_media_processing_enabled filter, so disabling client-side processing disables this path too. The browser-capability check (createImageBitmap + OffscreenCanvas + successful HEIC decode) still happens client-side, so setting the flag for all browsers is safe - Chromium browsers with the full pipeline ignore it.
  • Add unit tests covering the new flag for Chromium and non-Chromium user agents, and the disabled-by-filter case.

Testing

  • Before the patch: on a server lacking HEIC support, upload an HEIC file to Safari. Note that while the image shows (because Safari supports HEIC natively), the resizes do not work, no srcset is created and the image does not load if the post is loaded in Chrome or Firefox
  • Apply the patch and try again: the image is converted into JPEGs and uploaded. Checking the front end, srcset works, the image is a jpeg and works in Chrome/Firefox.

Trac ticket: https://core.trac.wordpress.org/ticket/65648

The block editor's HEIC canvas fallback is gated on
window.__heicUploadSupport, which core never set. Without it, browsers
that cannot use the full WebAssembly pipeline (such as Safari, which
lacks Document-Isolation-Policy support) get no client-side HEIC
conversion at all, even though they can decode HEIC natively via
createImageBitmap().

Set the flag in wp_set_client_side_media_processing_flag() alongside
the existing client-side media processing flags so Safari users get
HEIC uploads converted to JPEG in the browser.
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props adamsilverstein, andrewserong.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@adamsilverstein

adamsilverstein commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

I verified this fixes HEIC uploads for me in Safari. However, I notices a small visual glitch testing this, the image progress snackbar shows "1 of 2" even though I only uploaded one image. Chrome does not show this for the same image upload, its Safari specific.

I will open a follow up issue to work on this.

image

@adamsilverstein

Copy link
Copy Markdown
Member Author

I will open a follow up issue to work on this.

@andrewserong

Copy link
Copy Markdown
Contributor

The block editor's HEIC canvas fallback is gated on window.__heicUploadSupport, but core never sets that flag. The Gutenberg plugin sets it via gutenberg_set_heic_upload_support_flag(), and core has no equivalent.
As a result, on a core-only WordPress 7.1 install, browsers that cannot use the full WebAssembly (vips) pipeline get no client-side HEIC conversion at all. This primarily affects Safari:

At face value this makes it sound like something that should be fixed within the Gutenberg code. I.e. in Gutenberg we can add if ( globalThis.IS_GUTENBERG_PLUGIN ) { branches if we need to fork behaviour based on if it's running in the plugin versus core.

For this particular PHP change, since the conditions where we output window.__clientSideMediaProcessing = true;' and window.__heicUploadSupport = true; are indentical, I don't really understand why the latter is required.

Sorry if I'm missing something obvious!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants