Pass unsupported formats directly to the server#74910
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 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. |
|
Size Change: +50 B (0%) Total Size: 6.85 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in d7ee109. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/21646855553
|
When a file's MIME type is not in the list of client-side supported formats (JPEG, PNG, GIF, WebP, AVIF), skip client-side processing and upload it directly to the server. This allows formats like HEIC, TIFF, BMP, and SVG to be uploaded without failing at the client-side processing step. Includes prerequisite files (use-upload-save-lock.js, use-media-upload-settings.js) from the client-side media feature branch needed for provider/index.js changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
rebased on trunk |
| /** | ||
| * MIME types supported by client-side media processing. | ||
| * | ||
| * These are the image formats that can be processed using | ||
| * WebAssembly-based vips in the browser. | ||
| */ | ||
| export const CLIENT_SIDE_SUPPORTED_MIME_TYPES: readonly string[] = [ | ||
| 'image/jpeg', | ||
| 'image/png', | ||
| 'image/gif', | ||
| 'image/webp', | ||
| 'image/avif', | ||
| ]; |
There was a problem hiding this comment.
How was this list established?
In media-experiments I had this one:
(Also note the naming difference, image types vs mime types)
There was a problem hiding this comment.
Based on what we support in core already (which is whsat I'm trying to land), except core client side media won't support heic. Mayne need to add tif and jxl?
swissspidy
left a comment
There was a problem hiding this comment.
The idea of the upload store is that each and every single file should go through the upload queue. There shouldn't be any distinction between client- and server-side files. Only a single, shared implementation.
If a file isn't supported by vips, it would simply not be processed by it, but simply go through the queue unchanged, until it will be eventually uploaded to the server directly. That's what prepareItem in the store is fore.
The change here breaks this idea/assumption.
This would make for a great e2e test.
I think if every file goes to the queue properly (see comment above), then there shouldn't be a need for a second type of event. |
|
@andrewserong @swissspidy this one is ready for review. |
|
I left some feedback yesterday :) |
Ok, that makes sense. In that case, we would upload the file and set the flag so the server creates the subsizes (or in the case of PDF/Imagick the thumbnail version. |
Yes exactly, using the |
Instead of splitting files before the upload queue, check format support inside prepareItem() so all files go through the single upload queue. Unsupported formats (PDFs, SVGs, videos, etc.) skip vips operations and upload directly to the server. This addresses reviewer feedback that the queue should remain the single entry point for all uploads.
Thanks, was looking for that :) |
When a file is not processed by vips (unsupported image formats, PDFs, videos, etc.), set generate_sub_sizes to true so the server generates thumbnails. Vips-supported images keep generate_sub_sizes as false since thumbnails are created client-side.
@swissspidy - Updated to avoid a separate queue, please review. |
andrewserong
left a comment
There was a problem hiding this comment.
Not sure if it's the same bug as we saw elsewhere with the filenames, but when uploading non-image media, the filename of the file I'm uploading gets renamed (both as it exists on the server and in the block editor).
I.e I'd expect to see this after uploading a PDF:
But I actually see this (the type is used as the filename, and the file is unexpectedly document.pdf):
This appears to be happening on trunk, too, so not a blocker to landing this PR (just thought I'd mention it since I noticed while testing this PR, though).
As for this change, it's otherwise testing well for me! (Only the supported images are processed by vips, and the others appear to be passed through to the server 👍)
Noted. I'll work on this in a follow up. |
Summary
Depends on #74566
Fixes #74357
Changes
CLIENT_SIDE_SUPPORTED_MIME_TYPESconstant defining formats vips can handle (JPEG, PNG, GIF, WebP, AVIF)canProcessWithVips()helper function to check file compatibilityHow It Works
When a user uploads files with client-side media processing enabled:
canProcessWithVips()based on MIME typeTest Plan
🤖 Generated with Claude Code