Repository navigation
Description
Description
Follow-up to #86018, as discussed in this review and this comment.
When an upload through Replace → Upload fails, the Image, Audio and Video blocks clear the media they already had and go back to the placeholder:
- Image: the image, alt text, title and caption (
edit.jsxL137-L153, L208-L220) - Audio: the file and caption (
edit.jsxL103-L113) - Video: the file, poster and caption (
edit.jsxL99-L112)
#86018 fixed the same problem in the Playlist track (#85951): on a failed upload, it now clears only blob and the temporary URL. As noted in the review, clearing everything is probably left over from when the temporary blob URL was stored in src. These blocks now keep it in the blob attribute and a temporaryURL state, so clearing those should be enough.
Note for a fix: Replace → Reset calls the same handler with undefined to clear the media on purpose (Image, Audio, Video), so Reset needs to keep working.
Expected: after a failed upload, the block keeps its existing media and details, as the Playlist track does.
Actual: the block returns to the placeholder, and the media and its details are removed.
Step-by-step reproduction instructions
Server-side uploads must be active: in the editor console, window.__clientSideMediaProcessing should be undefined. If it is true, disable client-side processing with add_filter( 'wp_client_side_media_processing_enabled', '__return_false' );.
- Add an Image block with an image from the Media Library, and give it alt text and a caption.
- In the editor console, run the snippet below. Uploads fail until you reload the page.
- Select the block, choose Replace → Upload, and pick any image.
- An error notice appears, and the block returns to the placeholder. The image, alt text and caption are gone.
- Repeat with an Audio block (with a caption) and a Video block (with a poster and caption).
wp.apiFetch.use( ( options, next ) => {
if ( options.method === 'POST' && /^\/wp\/v2\/media(\?|$)/.test( options.path ?? '' ) ) {
return Promise.reject( { code: 'simulated_failure', message: 'Simulated upload failure.' } );
}
return next( options );
} );Screenshots, screen recording, code snippet
Image
Screen.Recording.2026-11-04.at.2.28.45.PM.mov
Video
Screen.Recording.2026-11-04.at.2.30.23.PM.mov
Audio
Screen.Recording.2026-11-04.at.2.31.40.PM.mov
Environment info
- WordPress Latest
- Gutenberg Trunk
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure
Activity