Image Blocks suddenly need recovering
-
I suddenly noticed that when I load some old posts in the editor, image blocks that previously worked fine are now switching – sometimes before my eyes – to say, “This block contains unexpected or invalid content.”
Pressing the “Attempt Recovery” button fixes the issue, but why is this happening? These images have been fine for years.
I did a bit more digging by duplicating one of the image blocks then recovering the duplicate, and comparing the HTML for the recovered block and the one that supposedly suddenly has a problem.
All of the blocks that were previously working fine but now show as broken contain custom image dimensions. In other words, in the HTML they have style=”width:XXXXpx;height:XXXXpx”
The fact that they have specific widths and heights means that these images are ones where I have, sometime in the past, used the image handles to drag them to create a different size on the page.
From my testing, I also think this is only an issue with image blocks created by converting content from the classic editor to Gutenberg blocks.
Why is this happening now? These posts were converted from the Classic Editor to Gutenberg blocks a couple of years ago, and the posts have been edited and updated recently without issue. Something must have changed in one of the more recent versions of WordPress to cause this.
Another test I performed was to test what the HTML looks like now when you create a new image block in Gutenberg and use the handles to adjust the image size. I see now, in WP6.3, it adds style=”aspect-ratio:1;width:XXXXpx;height:auto” .
I see that image aspect ratios were added in WP6.3, and it looks to me like this has broken the recognition of older image blocks that featured custom width and heights.
- The topic ‘Image Blocks suddenly need recovering’ is closed to new replies.