Skip to content

Media: Add HEIC canvas fallback for client-side processing #76732

@adamsilverstein

Description

@adamsilverstein

Description

HEIC (HEIF with HEVC codec) images are the default photo format on iPhones but are not universally supported by web servers or browsers. Currently, if the server lacks HEIC support (no ImageMagick HEVC module), uploads may fail entirely because wp_prevent_unsupported_mime_type_uploads blocks them.

Proposed Solution

Implement a server-first, canvas-fallback strategy:

  1. Upload HEIC to server, letting it try to process
  2. Sideload the original HEIC to the attachment as image_size: 'original' — the sideload response returns missing_image_sizes so we know what sub-sizes need to be generated
  3. If there are missing sizes, use browser-native createImageBitmap() + OffscreenCanvas to decode the HEIC and convert to JPEG
  4. Sideload the JPEG as the scaled version (web-friendly main image)
  5. Use the JPEG with the existing vips resize pipeline for sub-size generation
  6. Sideload each sub-size back to the attachment

This leverages browser-licensed HEVC decoding (Safari everywhere, Chrome on macOS, Chrome on Windows with codec) without shipping our own HEVC decoder, avoiding patent/licensing concerns.

Scenarios

Server HEIC support Browser HEIC support Result
Yes Any Server handles everything
No Yes Canvas fallback generates JPEG + sub-sizes
No No Error shown to user

Implementation

PR: #76731

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Client Side MediaMedia processing in the browser with WASM[Feature] MediaAnything that impacts the experience of managing media[Type] EnhancementA suggestion for improvement.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions