Skip to content

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

Closed

Description

@hbhalodia

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:

#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' );.

  1. Add an Image block with an image from the Media Library, and give it alt text and a caption.
  2. In the editor console, run the snippet below. Uploads fail until you reload the page.
  3. Select the block, choose Replace → Upload, and pick any image.
  4. An error notice appears, and the block returns to the placeholder. The image, alt text and caption are gone.
  5. 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

  1. self-assigned this
    on Nov 4, 2026
  2. added
    [Type] Bug
    [Package] Block library
    on Nov 4, 2026
  3. added theissue type on Nov 4, 2026
  4. added
    [Block] Image
    [Block] Video
    [Block] Audio
    on Nov 4, 2026
  5. added
    [Status] In Progress
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Block] Audio[Block] Image[Block] Video[Package] Block library[Status] In Progress[Type] Bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions