WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.48k stars 4.18k forks source link

Gutenberg Editor Image Scaling - Issues with Thumbnail Regenration - Missing Images #32441

Open shuttermuse opened 3 years ago

shuttermuse commented 3 years ago

When an image is inserted, either singularly, or with a gallery, Gutenberg is using the URL for the selected scaled version of the image. eg. image-name-500x1024.jpg

If a user changes their image sizes in Settings>Media, and then, as many people so often seem to suggest, regenerates their thumbnails using a plugin, this can cause major issues. Several of these thumbnail regeneration plugins delete (either by default or as an option) the old thumbnails.

With Gutenberg using the scaled image URL in the editor, this means when you go to edit an old post after doing this, all of your images are broken in the editor. When the post is viewed on the front end, there is no problem, but the editor will be filled with a mess of broken image icons. If someone does this by accident, it can be a while before the problem is realized. New posts will work fine, and old posts look ok on front end. The issue is only visible if you happen to go back and edit an old post. If your backup system does not keep backups for a longer period of time than it takes you to discover this issue, it could be a real headache that can only really be solved by deleting and then re-inserting all the images again into your old posts.

It would be great to have a way to prevent this. Perhaps by having the editor fall back to the URL of the original image when the scaled version is not available? Or by rewriting the scaled image URL to the URL of the closest new scaled version?

noisysocks commented 3 years ago

Related: https://github.com/WordPress/gutenberg/issues/28914, https://github.com/WordPress/gutenberg/issues/23262

This was a problem in the classic editor, too.

I suppose the image block could detect when loading the image has a 404 error and use the stored image ID to change the stored URL to a new URL.

It wouldn’t totally be automatic, the user would have to press Update, but that might be a nice thing to do that’s not updating post_content in every single post (maybe not even practical e.g. on a site with lots of posts).