Skip to content

Fix: Image, Audio, Video: A failed Replace upload removes the block's existing media - #86290

Merged
hbhalodia merged 5 commits into
WordPress:trunkfrom
hbhalodia:fix/issue-86289
Nov 4, 2026
Merged

hbhalodia merged 5 commits into
WordPress:trunkfrom
hbhalodia:fix/issue-86289

Conversation

@hbhalodia

@hbhalodia hbhalodia commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

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 src or url. They now keep it in the blob attribute and a temporaryURL state, so clearing those is enough.

#86018 made the same change for the Playlist track, and this follows up on the review there.

How?

  • On a failed upload, each block clears only blob and 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.
  • Image's onUploadError no longer clears url and id, so the image is also kept when the upload fails with client-side media processing, or when the file is rejected.
  • Reset used the same handler with 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.
    • Adds e2e tests for Image, Audio and Video that check a failed replacement keeps the media and Reset still removes it. Audio and Video get new spec files.

Testing Instructions

  1. Follow the steps in Image, Audio, Video: A failed Replace upload removes the block's existing media #86289. Each block keeps its media, details and caption after the failed upload, and an error notice appears.
  2. Choose Replace → Reset on each block. The block returns to the placeholder.
  3. For Image, open Settings → Media and use Reset all, then add an image again and remove the Image item. Both clear the image.
  4. Upload a file in an empty block while uploads are failing. The block stays a placeholder and the spinner stops.
  5. Reload, then replace the media with a successful upload. It works as before.
  6. Run 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.

@hbhalodia
hbhalodia requested a balanced review from Copilot November 4, 2026 09:27
@hbhalodia hbhalodia self-assigned this Nov 4, 2026
@hbhalodia hbhalodia added [Type] Bug An existing feature does not function as intended [Package] Block library /packages/block-library [Block] Image Affects the Image Block [Block] Video Affects the Video Block [Block] Audio Affects the Audio Block labels Nov 4, 2026
@hbhalodia
hbhalodia marked this pull request as ready for review November 4, 2026 09:28
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The audio, image, and video tests use a locator that also matches upload progress, allowing preservation checks or Reset to run before the replacement fails.

1 open issue

Review effort: Balanced

@hbhalodia
hbhalodia requested review from Mamaduka and a balanced review from Copilot November 4, 2026 11:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the media replacement upload fix.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@hbhalodia
hbhalodia enabled auto-merge (squash) November 4, 2026 11:51
@hbhalodia
hbhalodia merged commit 8a8f1b8 into WordPress:trunk Nov 4, 2026
87 of 88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Audio Affects the Audio Block [Block] Image Affects the Image Block [Block] Video Affects the Video Block [Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image, Audio, Video: A failed Replace upload removes the block's existing media

3 participants