Media: Enable AVIF support for client-side uploads#76371
Media: Enable AVIF support for client-side uploads#76371adamsilverstein merged 11 commits intotrunkfrom
Conversation
When generate_sub_sizes is false, the client handles all image processing via WASM/vips. The server's image editor support check in create_item_permissions_check rejects formats like AVIF even though the server doesn't need to process them. This bypasses that check using the wp_prevent_unsupported_mime_type_uploads filter when client-side processing is enabled.
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
The HEIF dynamic library (vips-heif.wasm) was excluded due to trademark concerns, but AVIF uses the royalty-free AV1 codec. Without this module, AVIF uploads fail with "buffer is not in a known format" because vips cannot decode AVIF buffers.
|
Size Change: +1.85 MB (+26.91%) 🚨 Total Size: 8.74 MB
ℹ️ View Unchanged
|
The core create_item_permissions_check reads file type from get_file_params(), which is only populated for multipart uploads. Raw body uploads via set_body() never triggered the check, so the tests were passing/failing for the wrong reasons. Test the permissions check method directly with file params set.
|
I confirmed via manual testing that this fixes AVIF uploads processing on the client. |
|
Note: the size change is expected here since we are adding libheif back to the build. |
wp_image_editor_supports is a function, not a filter hook. Use wp_image_editors filter with __return_empty_array to remove all editors, making wp_image_editor_supports() return false for the permissions check tests.
|
Flaky tests detected in 4fabd0c. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22940266925
|
Co-authored-by: Weston Ruter <[email protected]>
Co-authored-by: Weston Ruter <[email protected]>
Simplify generate_sub_sizes check since the param has a default value of true, remove redundant explicit true values in tests, and remove unnecessary remove_filter calls.
When calling create_item_permissions_check directly (not through REST dispatch), default param values aren't applied. The explicit set_param is needed so generate_sub_sizes isn't null, which would incorrectly trigger the bypass filter.
Co-authored-by: Weston Ruter <[email protected]>
Co-authored-by: Weston Ruter <[email protected]>
When uploading images via the REST API with `generate_sub_sizes` set to `false`, skip server support checks since processing is handled on the client side. Fix an issue where uploads of formats like AVIF fail with `rest_upload_image_type_not_supported`, even though the client will handle all image processing and the server doesn't need to support the format. See also WordPress/gutenberg#76369 and WordPress/gutenberg#76371. Props adamsilverstein, westonruter, andrewserong, mukesh27. Fixes #64836. See #62717. git-svn-id: https://develop.svn.wordpress.org/trunk@61980 602fd350-edb4-49c9-b593-d223f7449a82
When uploading images via the REST API with `generate_sub_sizes` set to `false`, skip server support checks since processing is handled on the client side. Fix an issue where uploads of formats like AVIF fail with `rest_upload_image_type_not_supported`, even though the client will handle all image processing and the server doesn't need to support the format. See also WordPress/gutenberg#76369 and WordPress/gutenberg#76371. Props adamsilverstein, westonruter, andrewserong, mukesh27. Fixes #64836. See #62717. Built from https://develop.svn.wordpress.org/trunk@61980 git-svn-id: http://core.svn.wordpress.org/trunk@61262 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* Media: Skip server image support check for client-side uploads When generate_sub_sizes is false, the client handles all image processing via WASM/vips. Also enable include the library supporting AVIF in the worker. --------- Co-authored-by: Weston Ruter <[email protected]>
|
I just cherry-picked this PR to the wp/7.0 branch to get it included in the next release: 727f6e5 |
This updates the pinned hash from the `gutenberg` from `9b8144036fa5faf75de43d4502ff9809fcf689ad` to `8c78d87453509661a9f28f978ba2c242d515563b`. The following changes are included: - Navigation Editor: Allow any blocks to be inserted by gating contentOnly insertion rules to section blocks (WordPress/gutenberg#76189) - Add `fetchpriority=low` to `IMG` tags in collapsed Details blocks (WordPress/gutenberg#76269) - Connectors: Add logo URL support for custom AI providers (WordPress/gutenberg#76190) - Cover Block: Add a playlist parameter to loop YouTube background videos. (WordPress/gutenberg#76004) - Connectors: Memoize getConnectors selector (WordPress/gutenberg#76339) - HTML Block: Fix broken layout (WordPress/gutenberg#76278) - Tests: Skip connector logo URL tests when AI Client is unavailable (WordPress/gutenberg#76343) - Navigation Overlay: Explicitly set fetchpriority for images (WordPress/gutenberg#76208) - Connectors: Show API key source for env vars and wp-config constants (WordPress/gutenberg#76355) - Connectors: Move API key validation and masking to REST dispatch level (WordPress/gutenberg#76327) - Connectors: Replace apiFetch with core-data store selectors (WordPress/gutenberg#76333) - Do not sync local attributes (WordPress/gutenberg#76267) - Add `fetchpriority=low` to `IMG` tags in collapsed Accordion Item blocks (WordPress/gutenberg#76336) - Implement disconnection debounce after initial connection (WordPress/gutenberg#76114) - Allow Post Content to be edited when 'Show template' is active and Post content is nested in a Template Part (WordPress/gutenberg#76305) - Fix: Document Bar: Back button flickers (WordPress/gutenberg#76320) - RTC: Move event hooks from editor to core-data (WordPress/gutenberg#76358) - fix(navigation): prevent right-justified submenu overflow in custom overlays (WordPress/gutenberg#76360) - Connectors: Add connectors registry for extensibility (WordPress/gutenberg#76364) - Connectors: Add empty state when no connectors are registered (WordPress/gutenberg#76375) - Temp: Disable RTC in the site editor (WordPress/gutenberg#76223) - Connectors: Add AI Experiments plugin callout with install/activate functionality (WordPress/gutenberg#76379) - Editor: Polish real-time collaboration presence UI and move Avatar to editor package (WordPress/gutenberg#75652) (WordPress/gutenberg#76365) - RTC: Add collaborator selection highlighting in rich text (WordPress/gutenberg#76107) - Sync changes from `wp_enqueue_global_styles()` to Gutenberg override (WordPress/gutenberg#76127) - [RTC] Fix performance regression on post save (WordPress/gutenberg#76370) - Media: Enable AVIF support for client-side uploads (WordPress/gutenberg#76371) - Connectors: Move plugin status computation to script module data (WordPress/gutenberg#76409) - Revisions: Skip rendered fields in REST API responses (WordPress/gutenberg#76347) - E2E Tests: Add connector setup flow tests with test AI provider (WordPress/gutenberg#76433) - RTC: Place sync connection modal in front of popover (WordPress/gutenberg#76431) - Connectors: Sync PHP code with WordPress Core (WordPress/gutenberg#76443) - Editor: Show own presence in collaborative editing sessions (WordPress/gutenberg#76413) (WordPress/gutenberg#76445) A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/9b8144036fa5faf75de43d4502ff9809fcf689ad…8c78d87453509661a9f28f978ba2c242d515563b. Log created with: git log --reverse --format="- %s" 9b8144036fa5faf75de43d4502ff9809fcf689ad..8c78d87453509661a9f28f978ba2c242d515563b | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy See #64595. git-svn-id: https://develop.svn.wordpress.org/trunk@61988 602fd350-edb4-49c9-b593-d223f7449a82
This updates the pinned hash from the `gutenberg` from `9b8144036fa5faf75de43d4502ff9809fcf689ad` to `8c78d87453509661a9f28f978ba2c242d515563b`. The following changes are included: - Navigation Editor: Allow any blocks to be inserted by gating contentOnly insertion rules to section blocks (WordPress/gutenberg#76189) - Add `fetchpriority=low` to `IMG` tags in collapsed Details blocks (WordPress/gutenberg#76269) - Connectors: Add logo URL support for custom AI providers (WordPress/gutenberg#76190) - Cover Block: Add a playlist parameter to loop YouTube background videos. (WordPress/gutenberg#76004) - Connectors: Memoize getConnectors selector (WordPress/gutenberg#76339) - HTML Block: Fix broken layout (WordPress/gutenberg#76278) - Tests: Skip connector logo URL tests when AI Client is unavailable (WordPress/gutenberg#76343) - Navigation Overlay: Explicitly set fetchpriority for images (WordPress/gutenberg#76208) - Connectors: Show API key source for env vars and wp-config constants (WordPress/gutenberg#76355) - Connectors: Move API key validation and masking to REST dispatch level (WordPress/gutenberg#76327) - Connectors: Replace apiFetch with core-data store selectors (WordPress/gutenberg#76333) - Do not sync local attributes (WordPress/gutenberg#76267) - Add `fetchpriority=low` to `IMG` tags in collapsed Accordion Item blocks (WordPress/gutenberg#76336) - Implement disconnection debounce after initial connection (WordPress/gutenberg#76114) - Allow Post Content to be edited when 'Show template' is active and Post content is nested in a Template Part (WordPress/gutenberg#76305) - Fix: Document Bar: Back button flickers (WordPress/gutenberg#76320) - RTC: Move event hooks from editor to core-data (WordPress/gutenberg#76358) - fix(navigation): prevent right-justified submenu overflow in custom overlays (WordPress/gutenberg#76360) - Connectors: Add connectors registry for extensibility (WordPress/gutenberg#76364) - Connectors: Add empty state when no connectors are registered (WordPress/gutenberg#76375) - Temp: Disable RTC in the site editor (WordPress/gutenberg#76223) - Connectors: Add AI Experiments plugin callout with install/activate functionality (WordPress/gutenberg#76379) - Editor: Polish real-time collaboration presence UI and move Avatar to editor package (WordPress/gutenberg#75652) (WordPress/gutenberg#76365) - RTC: Add collaborator selection highlighting in rich text (WordPress/gutenberg#76107) - Sync changes from `wp_enqueue_global_styles()` to Gutenberg override (WordPress/gutenberg#76127) - [RTC] Fix performance regression on post save (WordPress/gutenberg#76370) - Media: Enable AVIF support for client-side uploads (WordPress/gutenberg#76371) - Connectors: Move plugin status computation to script module data (WordPress/gutenberg#76409) - Revisions: Skip rendered fields in REST API responses (WordPress/gutenberg#76347) - E2E Tests: Add connector setup flow tests with test AI provider (WordPress/gutenberg#76433) - RTC: Place sync connection modal in front of popover (WordPress/gutenberg#76431) - Connectors: Sync PHP code with WordPress Core (WordPress/gutenberg#76443) - Editor: Show own presence in collaborative editing sessions (WordPress/gutenberg#76413) (WordPress/gutenberg#76445) A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/9b8144036fa5faf75de43d4502ff9809fcf689ad…8c78d87453509661a9f28f978ba2c242d515563b. Log created with: git log --reverse --format="- %s" 9b8144036fa5faf75de43d4502ff9809fcf689ad..8c78d87453509661a9f28f978ba2c242d515563b | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy See #64595. Built from https://develop.svn.wordpress.org/trunk@61988 git-svn-id: http://core.svn.wordpress.org/trunk@61270 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Summary
Fixes #76369.
Enables end-to-end client-side AVIF upload support with two changes:
1. Skip server image support check for client-side uploads
When client-side media processing is enabled (
generate_sub_sizes=false), the server doesn't need to process the image — the browser handles everything via WASM/vips. However, WordPress core'screate_item_permissions_check()rejects uploads for image formats the server's image editor doesn't support (e.g. AVIF on servers without AVIF support), returningrest_upload_image_type_not_supportedbeforecreate_item()even runs.create_item_permissions_check()inGutenberg_REST_Attachments_Controllerto bypass the server support check via thewp_prevent_unsupported_mime_type_uploadsfilter whengenerate_sub_sizesisfalse2. Load HEIF module in wasm-vips for AVIF decoding
The HEIF dynamic library (
vips-heif.wasm) was previously excluded due to trademark concerns around HEIF (Nokia patents). However, AVIF uses the royalty-free AV1 codec from the Alliance for Open Media. Without this module, vips cannot decode AVIF buffers, causing uploads to fail with "buffer is not in a known format".vips-heif.wasmtodynamicLibrariesandlocateFilein the vips workerTest plan
rest_upload_image_type_not_supported