Repository navigation
Fix: Image, Audio, Video: A failed Replace upload removes the block's existing media - #86290
Conversation
…t the old attributes value
🤖 PR meta 🤖🎉 PropsIf 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the changes intended to preserve existing media after failed replacement uploads while retaining explicit reset behavior.
No open issues 🎉
What changed in this PR
Extends the Playlist track fix to Image, Audio, and Video blocks so failed replacement uploads preserve existing media and details while explicit Reset actions still clear them.
Changes:
- Clears only temporary upload state on failure.
- Adds dedicated reset handlers, including Image’s Media panel controls.
- Adds an Image end-to-end regression test and a changelog entry.
| File | Description |
|---|---|
test/e2e/specs/editor/blocks/image.spec.js |
Tests image preservation after a failed upload and removal through Reset. |
packages/block-library/src/video/edit.jsx |
Preserves video details on failure and separates reset handling. |
packages/block-library/src/image/image.jsx |
Connects toolbar and Media panel controls to the dedicated reset handler. |
packages/block-library/src/image/edit.jsx |
Preserves image attributes on upload errors and adds explicit reset handling. |
packages/block-library/src/audio/edit.jsx |
Preserves audio details on failure and separates reset handling. |
packages/block-library/CHANGELOG.md |
Documents the failed replacement upload fix. |
Review effort: Balanced

What?
Closes #86289
When an upload through Replace → Upload fails, the Image, Audio and Video blocks now keep their current media and its details, instead of returning to the placeholder. Reset still removes the media.
Why?
On a failed upload, these blocks cleared all their media attributes, which is probably left over from when the temporary blob URL was stored in
srcorurl. They now keep it in theblobattribute and atemporaryURLstate, so clearing those is enough.#86018 made the same change for the Playlist track, and this follows up on the review there.
How?
bloband the temporary URL, as Fix: Playlist: A failed Replace upload clears the track's title, artist, album, image and length #86018 does for the Playlist track.onUploadErrorno longer clearsurlandid, so the image is also kept when the upload fails with client-side media processing, or when the file is rejected.undefined, so each block now has its own reset handler that clears the media as before. For Image, this also covers Reset all and removing the Image item in the Media panel.Testing Instructions
npm run test:e2e -- test/e2e/specs/editor/blocks/image.spec.js test/e2e/specs/editor/blocks/audio.spec.js test/e2e/specs/editor/blocks/video.spec.js.Screenshots or screencast
Screen.Recording.2026-11-04.at.2.47.02.PM.mov
Use of AI Tools
I used Claude Code (Claude Opus 5.5) to trace the cause and draft the fix, the tests, and this description. I reviewed and tested the changes myself.