Skip to content

Temporarily broken images silently empties Image Block attributes #41161

@eriktorsner

Description

@eriktorsner

Description

In PR #35973 an error handler onImageError() was introduced in the Image Block with the intention to handle when images are removed from the Media Library. If the image is removed, the Image Block gets its id and URL attributes cleared out.

However, this behavior is also triggered when a local or remote image is just temporarily unavailable for any reason. For many users, this will be unwanted behavior.

There are many situations where an image can be unavailable for a short period of time without meaning that the image is broken forever and should be removed.

For remote images:

  1. Network issues including DNS problems
  2. Access control issues i.e due to config changes in a Cloud Front distribution
  3. Maintenance work
  4. Domain or SSL certificate problems.

For local images there are a few potential reasons as well:

  1. Images may be stored on a different file system that is temporarily unavailable
  2. Images may be intentionally removed from the local webserver by a plugin like WP Offload Media but with core issues like 54931 a local URL may be sent to the block editor.

Imagine a situation where a webmaster of a media-heavy site notes that the CDN is currently broken and then decides to edit the front page on the site to inform users of the problem. Well, now they have two problems.

Step-by-step reproduction instructions

On WordPress 6.0-RC2 (or any version of Gutenberg with the 35973 PR in place)

  1. Create a new page in the block editor
  2. Add an image block, click "Insert from URL" and use https://s.w.org/images/home/screen-themes.png
  3. Publish the page and exit the editor.
  4. View the page on the front end just to make sure the image is there.
  5. Now block access to the s.w.org domain using any suitable method on your computer. On Mac/Linux the easiest way is to add the line 127.0.0.1 s.w.org to /etc/hosts
  6. Verify on the front end that the image no longer shows up.
  7. Open the page in the editor. (note that due to browser caching, the image may still be visible. Clear the browser cache if needed)
  8. Note that the image block is now transformed to its original state, asking the user to upload an image or pick one from the Media Library.

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 6.0-RC2 with Gutenberg 13?
  • Theme: twentytwentytwo
  • Server: nginx/1.21.6 using PHP 7.4.29
  • Db: MySQL 8.0.29

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

Metadata

Metadata

Assignees

Labels

[Block] ImageAffects the Image Block[Feature] MediaAnything that impacts the experience of managing media[Type] BugAn existing feature does not function as intended

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions