Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image blocks with set dimensions become invalid on upgrade from WordPress 6.0.3 to 6.4.2 #56916

Open
jg314 opened this issue Dec 8, 2023 · 24 comments · Fixed by #57063
Open
Assignees
Labels
[Block] Image Affects the Image Block [Feature] Block Validation/Deprecation Handling block validation to determine accuracy and deprecation [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@jg314
Copy link
Contributor

jg314 commented Dec 8, 2023

Description

Image blocks with set dimensions break when WordPress is upgraded from 6.0.3 to 6.4.2.

Step-by-step reproduction instructions

  1. Install WordPress 6.0.3.
  2. Create a page and add an Image block with an image inside of it.
  3. Set the width and height of the image in the block's settings.
  4. Save your changes.
  5. Upgrade WordPress to version 6.4.2.
  6. Visit the same URL used to edit the page where you had originally added the image.
  7. Make any change, such as adding a paragraph beneath the Image block.
  8. Save your changes and reload the page.
  9. You'll see a block validation error on the image.

Screenshots, screen recording, code snippet

image (1)

Environment info

  • WordPress Version: 6.0.3 & 6.4.2
  • Desktop Environment: Windows 11
  • Browser: Google Chrome

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

@jg314 jg314 added the [Type] Bug An existing feature does not function as intended label Dec 8, 2023
@jordesign jordesign added Needs Testing Needs further testing to be confirmed. [Block] Image Affects the Image Block labels Dec 10, 2023
@mt8
Copy link

mt8 commented Dec 13, 2023

Our team tested this issue.

The environment is below.

WordPress before update: 6.2.3

WordPress after update: 6.4.2

Image block code added in 6.2.3 and changed width and height

<!-- wp:image {"id":2212,"width":690,"height":500,"sizeSlug":"large","linkDestination":"none"} -->

<figure class="wp-block-image size-large is-resized">
  <img src="http://localhost/wp620/wp-content/uploads/webp01-1-693x520.webp" alt="" class ="wp-image-2212" width="690" height="500"/>
</figure>

<!-- /wp:image -->

Code after updating to 6.4.2, adding paragraph block and saving

<!-- wp:image {"id":2212,"width":690,"height":500,"sizeSlug":"large","linkDestination":"none"} -->

<figure class="wp-block-image size-large is-resized">
  <img src="http://localhost/wp620/wp-content/uploads/webp01-1-693x520.webp" alt="" class ="wp-image-2212" style="width:690px;height:500px"/>
</figure>

<!-- /wp:image -->

It seems that the width and height specifications of the <figure><img> tag have been changed to style attributes.

width="690" height="500" changes to style="width:690px;height:500px".

However, if you save without adding a paragraph block, the <figure><img> tag remains unchanged.

@jg314
Copy link
Contributor Author

jg314 commented Dec 13, 2023

Thanks for hopping in here @mt8. When you did your testing, did you see the same block error that I did?

Also, did you happen to test this starting with WordPress 6.0.3, which is the Core version where I saw the issue?

@mt8
Copy link

mt8 commented Dec 13, 2023

Hello, @jg314

Did you get the same blocking error as me when you did the test?

Yes, I confirmed the same error.

Also, did you test this from WordPress 6.0.3, which is the core version where I saw the issue?

Yes, after confirming that it can be reproduced in 6.0.3, I also reproduced it in 6.2.3 I'm thinking this is probably a 6.4 issue since it reproduces on 6.3.x as well.

@jg314
Copy link
Contributor Author

jg314 commented Dec 13, 2023

Thanks for the quick reply @mt8.

I'm thinking this is probably a 6.4 issue since it reproduces on 6.3.x as well.

We were actually able to replicate the issue upgrading from 6.0.3 to 6.3.2 as well, so it looks like this started before 6.4.

Again, really appreciate you doing some additional testing.

@t-hamano t-hamano added [Feature] Block Validation/Deprecation Handling block validation to determine accuracy and deprecation and removed Needs Testing Needs further testing to be confirmed. labels Dec 13, 2023
@t-hamano
Copy link
Contributor

From what I've researched, I think this problem is caused by a deprecation in WP6.3.

Test procedure

  • Insert an image block and set width and height in specific WP version
  • Update to specific WP version
  • Update the content of articles with images inserted
  • Save the post and reload the browser

Block markup in 6.2.3

<!-- wp:image {"id":13,"width":500,"height":300,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full is-resized">
  <img src="http://localhost:8888/wp-content/uploads/2023/12/test.jpg" alt="" class="wp-image-13" width="500" height="300"/>
</figure>
<!-- /wp:image -->

Block markup in 6.3.2

<!-- wp:image {"id":13,"width":"500px","height":"300px","scale":"cover","sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full is-resized">
  <img src="http://localhost:8888/wp-content/uploads/2023/12/test.jpg" alt="" class="wp-image-13" style="object-fit:cover;width:500px;height:300px"/>
</figure>
<!-- /wp:image -->

Update from 6.2.3 to 6.3.2

❌ The below error appears in the browser console and the block breaks.

Content generated by `save` function:

<figure class="wp-block-image size-full is-resized"><img src="http://localhost:8888/wp-content/uploads/2023/12/test.jpg" alt="" class="wp-image-13"/></figure>

Content retrieved from post body:

<figure class="wp-block-image size-full is-resized"><img src="http://localhost:8888/wp-content/uploads/2023/12/test.jpg" alt="" class="wp-image-13" style="width:500px;height:300px"/></figure>

Update from 6.2.3 to 6.4.2

❌ The below error appears in the browser console and the block breaks.

<!-- wp:image {"id":13,"width":500,"height":300,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full is-resized"><img src="http://localhost:8888/wp-content/uploads/2023/12/test.jpg" alt="" class="wp-image-13" style="width:500px;height:300px"/></figure>
<!-- /wp:image -->

Content generated by `save` function:

<figure class="wp-block-image size-full is-resized"><img src="http://localhost:8888/wp-content/uploads/2023/12/test.jpg" alt="" class="wp-image-13"/></figure>

Content retrieved from post body:

<figure class="wp-block-image size-full is-resized"><img src="http://localhost:8888/wp-content/uploads/2023/12/test.jpg" alt="" class="wp-image-13" style="width:500px;height:300px"/></figure>

Update from 6.3.2 to 6.4.2

✅ The block is unbreakable

@t-hamano t-hamano self-assigned this Dec 14, 2023
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Dec 14, 2023
@t-hamano
Copy link
Contributor

I believe #57063 should fix this issue.

@jg314
Copy link
Contributor Author

jg314 commented Dec 18, 2023

It's fantastic to see you all merge a fix this quickly. Thanks for getting to this so fast @t-hamano!

Is there somewhere to easily see whether this fix will be included in a maintenance release for WordPress 6.3 or 6.4?

@t-hamano
Copy link
Contributor

Is there somewhere to easily see whether this fix will be included in a maintenance release for WordPress 6.3 or 6.4?

At least it will be included in 6.5, but I'm not sure if it's possible to backport this to 6.3 and 6.4.

Do @mikachan and @annezazu know about maintenance releases?

@annezazu
Copy link
Contributor

I'll cc @aaronjorbin for this once more as I can see he's been wrangling for 6.4.3 at least on the broader Core side.

@mikachan
Copy link
Member

👋 I'm happy to help with pulling the related PR into the Core package updates, if there are no objections to it being included in a point release.

@t-hamano
Copy link
Contributor

Thank you @mikachan! If there is anything I can do, please contact me at any time.

@aaronjorbin
Copy link
Member

This seems like a great candidate for 6.4. Thanks @annezazu for the flag and @mikachan for ensuring it makes it over there.

At least it will be included in 6.5, but I'm not sure if it's possible to backport this to 6.3 and 6.4.

For clarity sake, I want to note that now that 6.4 is released, no bug fixes will be backported to 6.3. While security fixes are often backported as a courtesy to people who have not been able to update for whatever reason, only one version of WordPress is actively maintained at a time.

@jg314
Copy link
Contributor Author

jg314 commented Dec 27, 2023

Thanks for clarifying @aaronjorbin. Can you recommend an approach to get this code fix into a WordPress 6.3 installation that doesn't involve upgrading to 6.4? Our team manages a large multisite network which usually takes weeks and a lot of work to upgrade to the newest version of WordPress. Doing that only for this bug fix doesn't seem like the highest leverage use of time.

@NicktheGeek
Copy link

I'm seeing this bug in a site running 6.4.3. Was this not able to go into the 6.4.3 release? I don't see any confirmation that it was included.

@t-hamano
Copy link
Contributor

@NicktheGeek

It is announced here: https://wordpress.org/documentation/wordpress-version/version-6-4-3/

Here is the pull requests for the block editor backported to 6.4.3: WordPress/wordpress-develop#5698

Could you tell me the specific details of the error that is occurring?

@NicktheGeek
Copy link

@t-hamano sure.
Site was created at WP 6.2 so all content was created then. There was a bug affecting one of the plugins and WP 6.3 so we didn't update to 6.3 when it dropped. The plugin author released a fix and we updated to wp 6.4 including the latest 6.4.3 release.

Some, not all, images have an error. It appears to specifically affect images that had the height/width set and it sure looks the same as what was reported in this.

Block validation failed for Core/Image
Content generated by save function:

<figure class="wp-block-image aligncenter size-large has-custom-border is-resized is-style-rounded ghostkit-custom-1ClGpW"><img src="{radacted}.png?w=800" alt="" class="wp-image-3587" style="border-style:none;border-width:0px"/></figure>

Content retrieved from post body:

<figure class="wp-block-image aligncenter size-large is-resized has-custom-border is-style-rounded ghostkit-custom-1ClGpW"><img src="{redacted}.png?w=800" alt="" class="wp-image-3587" style="border-style:none;border-width:0px;width:200px;height:200px"/></figure>

Here is the object included with the error.

{
    "name": "core/image",
    "icon": {
        "src": {
            "type": {
                "displayName": "SVG"
            },
            "key": null,
            "ref": null,
            "props": {
                "viewBox": "0 0 24 24",
                "xmlns": "http://www.w3.org/2000/svg",
                "children": {
                    "key": null,
                    "ref": null,
                    "props": {
                        "d": "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v8.4l-3-2.9c-.3-.3-.8-.3-1 0L11.9 14 9 12c-.3-.2-.6-.2-.8 0l-3.6 2.6V5c-.1-.3.1-.5.4-.5zm14 15H5c-.3 0-.5-.2-.5-.5v-2.4l4.1-3 3 1.9c.3.2.7.2.9-.1L16 12l3.5 3.4V19c0 .3-.2.5-.5.5z"
                    },
                    "_owner": null
                }
            },
            "_owner": null
        }
    },
    "keywords": [
        "img",
        "photo",
        "picture",
        "google photos",
        "pexels",
        "openverse"
    ],
    "attributes": {
        "align": {
            "type": "string"
        },
        "url": {
            "type": "string",
            "source": "attribute",
            "selector": "img",
            "attribute": "src",
            "__experimentalRole": "content"
        },
        "alt": {
            "type": "string",
            "source": "attribute",
            "selector": "img",
            "attribute": "alt",
            "default": "",
            "__experimentalRole": "content"
        },
        "caption": {
            "type": "string",
            "source": "html",
            "selector": "figcaption",
            "__experimentalRole": "content"
        },
        "lightbox": {
            "type": "object",
            "enabled": {
                "type": "boolean"
            }
        },
        "title": {
            "type": "string",
            "source": "attribute",
            "selector": "img",
            "attribute": "title",
            "__experimentalRole": "content"
        },
        "href": {
            "type": "string",
            "source": "attribute",
            "selector": "figure > a",
            "attribute": "href",
            "__experimentalRole": "content"
        },
        "rel": {
            "type": "string",
            "source": "attribute",
            "selector": "figure > a",
            "attribute": "rel"
        },
        "linkClass": {
            "type": "string",
            "source": "attribute",
            "selector": "figure > a",
            "attribute": "class"
        },
        "id": {
            "type": "number",
            "__experimentalRole": "content"
        },
        "width": {
            "type": "string"
        },
        "height": {
            "type": "string"
        },
        "aspectRatio": {
            "type": "string"
        },
        "scale": {
            "type": "string"
        },
        "sizeSlug": {
            "type": "string"
        },
        "linkDestination": {
            "type": "string"
        },
        "linkTarget": {
            "type": "string",
            "source": "attribute",
            "selector": "figure > a",
            "attribute": "target"
        },
        "lock": {
            "type": "object"
        },
        "ghostkitId": {
            "type": "string"
        },
        "ghostkitClassname": {
            "type": "string"
        },
        "ghostkitStyles": {
            "type": "object"
        },
        "ghostkitSR": {
            "type": "string"
        },
        "ghostkitCustomCSS": {
            "type": "string"
        },
        "ghostkitPosition": {
            "type": "object"
        },
        "ghostkitSpacings": {
            "type": "object"
        },
        "ghostkitFrame": {
            "type": "object"
        },
        "style": {
            "type": "object"
        },
        "borderColor": {
            "type": "string"
        },
        "className": {
            "type": "string"
        },
        "ghostkit": {
            "type": "object"
        },
        "anchor": {
            "type": "string",
            "source": "attribute",
            "attribute": "id",
            "selector": "*"
        }
    },
    "providesContext": {},
    "usesContext": [
        "allowResize",
        "imageCrop",
        "fixedHeight"
    ],
    "selectors": {
        "border": ".wp-block-image img, .wp-block-image .wp-block-image__crop-area, .wp-block-image .components-placeholder",
        "filter": {
            "duotone": ".wp-block-image img, .wp-block-image .components-placeholder"
        }
    },
    "supports": {
        "anchor": true,
        "color": {
            "text": false,
            "background": false
        },
        "filter": {
            "duotone": true
        },
        "__experimentalBorder": {
            "color": true,
            "radius": true,
            "width": true,
            "__experimentalSkipSerialization": true,
            "__experimentalDefaultControls": {
                "color": true,
                "radius": true,
                "width": true
            }
        },
        "ghostkit": {
            "attributes": true,
            "styles": {
                "customSelector": false
            },
            "position": {
                "position": true,
                "distance": true,
                "width": true,
                "height": true,
                "minMaxWidth": true,
                "minMaxHeight": true,
                "zIndex": true
            },
            "spacings": {
                "padding": true,
                "margin": true
            },
            "frame": {
                "border": true,
                "borderRadius": true,
                "shadow": true
            },
            "transform": {
                "translate": true,
                "scale": true,
                "rotate": true,
                "skew": true,
                "perspective": true,
                "origin": true
            },
            "customCSS": {
                "opacity": true,
                "overflow": true,
                "cursor": true,
                "userSelect": true,
                "clipPath": true,
                "custom": true,
                "transition": true
            },
            "display": {
                "screenSize": true
            },
            "effects": {
                "reveal": true,
                "mouseHover": true,
                "mousePress": true,
                "mouseMove": true,
                "scroll": true,
                "loop": true
            }
        }
    },
    "styles": [
        {
            "name": "default",
            "label": "Default",
            "isDefault": true
        },
        {
            "name": "rounded",
            "label": "Rounded"
        }
    ],
    "variations": [],
    "blockHooks": [],
    "apiVersion": 3,
    "title": "Image",
    "description": "Insert an image to make a visual statement.",
    "category": "media",
    "example": {
        "attributes": {
            "sizeSlug": "large",
            "url": "https://s.w.org/images/core/5.3/MtBlanc1.jpg",
            "caption": "Mont Blanc appears—still, snowy, and serene."
        }
    },
    "transforms": {
        "from": [
            {
                "type": "raw"
            },
            {
                "type": "files"
            },
            {
                "type": "shortcode",
                "tag": "caption",
                "attributes": {
                    "url": {
                        "type": "string",
                        "source": "attribute",
                        "attribute": "src",
                        "selector": "img"
                    },
                    "alt": {
                        "type": "string",
                        "source": "attribute",
                        "attribute": "alt",
                        "selector": "img"
                    },
                    "caption": {},
                    "href": {},
                    "rel": {},
                    "linkClass": {},
                    "id": {
                        "type": "number"
                    },
                    "align": {
                        "type": "string"
                    }
                }
            }
        ]
    },
    "deprecated": [
        {
            "attributes": {
                "align": {
                    "type": "string"
                },
                "behaviors": {
                    "type": "object"
                },
                "url": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "src",
                    "__experimentalRole": "content"
                },
                "alt": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "alt",
                    "default": "",
                    "__experimentalRole": "content"
                },
                "caption": {
                    "type": "string",
                    "source": "html",
                    "selector": "figcaption",
                    "__experimentalRole": "content"
                },
                "title": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "title",
                    "__experimentalRole": "content"
                },
                "href": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "href",
                    "__experimentalRole": "content"
                },
                "rel": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "rel"
                },
                "linkClass": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "class"
                },
                "id": {
                    "type": "number",
                    "__experimentalRole": "content"
                },
                "width": {
                    "type": "string"
                },
                "height": {
                    "type": "string"
                },
                "aspectRatio": {
                    "type": "string"
                },
                "scale": {
                    "type": "string"
                },
                "sizeSlug": {
                    "type": "string"
                },
                "linkDestination": {
                    "type": "string"
                },
                "linkTarget": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "target"
                },
                "ghostkitId": {
                    "type": "string"
                },
                "ghostkitClassname": {
                    "type": "string"
                },
                "ghostkitStyles": {
                    "type": "object"
                },
                "ghostkitSR": {
                    "type": "string"
                },
                "ghostkitCustomCSS": {
                    "type": "string"
                },
                "ghostkitPosition": {
                    "type": "object"
                },
                "ghostkitSpacings": {
                    "type": "object"
                },
                "ghostkitFrame": {
                    "type": "object"
                },
                "lock": {
                    "type": "object"
                },
                "anchor": {
                    "type": "string",
                    "source": "attribute",
                    "attribute": "id",
                    "selector": "*"
                },
                "className": {
                    "type": "string"
                },
                "borderColor": {
                    "type": "string"
                },
                "style": {
                    "type": "object"
                }
            },
            "supports": {
                "anchor": true,
                "color": {
                    "text": false,
                    "background": false
                },
                "filter": {
                    "duotone": true
                },
                "__experimentalBorder": {
                    "color": true,
                    "radius": true,
                    "width": true,
                    "__experimentalSkipSerialization": true,
                    "__experimentalDefaultControls": {
                        "color": true,
                        "radius": true,
                        "width": true
                    }
                }
            }
        },
        {
            "attributes": {
                "align": {
                    "type": "string"
                },
                "url": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "src",
                    "__experimentalRole": "content"
                },
                "alt": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "alt",
                    "default": "",
                    "__experimentalRole": "content"
                },
                "caption": {
                    "type": "string",
                    "source": "html",
                    "selector": "figcaption",
                    "__experimentalRole": "content"
                },
                "title": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "title",
                    "__experimentalRole": "content"
                },
                "href": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "href",
                    "__experimentalRole": "content"
                },
                "rel": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "rel"
                },
                "linkClass": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "class"
                },
                "id": {
                    "type": "number",
                    "__experimentalRole": "content"
                },
                "width": {
                    "type": "number"
                },
                "height": {
                    "type": "number"
                },
                "aspectRatio": {
                    "type": "string"
                },
                "scale": {
                    "type": "string"
                },
                "sizeSlug": {
                    "type": "string"
                },
                "linkDestination": {
                    "type": "string"
                },
                "linkTarget": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "target"
                },
                "ghostkitId": {
                    "type": "string"
                },
                "ghostkitClassname": {
                    "type": "string"
                },
                "ghostkitStyles": {
                    "type": "object"
                },
                "ghostkitSR": {
                    "type": "string"
                },
                "ghostkitCustomCSS": {
                    "type": "string"
                },
                "ghostkitPosition": {
                    "type": "object"
                },
                "ghostkitSpacings": {
                    "type": "object"
                },
                "ghostkitFrame": {
                    "type": "object"
                },
                "lock": {
                    "type": "object"
                },
                "anchor": {
                    "type": "string",
                    "source": "attribute",
                    "attribute": "id",
                    "selector": "*"
                },
                "className": {
                    "type": "string"
                },
                "borderColor": {
                    "type": "string"
                },
                "style": {
                    "type": "object"
                }
            },
            "supports": {
                "anchor": true,
                "color": {
                    "text": false,
                    "background": false
                },
                "filter": {
                    "duotone": true
                },
                "__experimentalBorder": {
                    "color": true,
                    "radius": true,
                    "width": true,
                    "__experimentalSkipSerialization": true,
                    "__experimentalDefaultControls": {
                        "color": true,
                        "radius": true,
                        "width": true
                    }
                }
            }
        },
        {
            "attributes": {
                "align": {
                    "type": "string"
                },
                "url": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "src",
                    "__experimentalRole": "content"
                },
                "alt": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "alt",
                    "default": "",
                    "__experimentalRole": "content"
                },
                "caption": {
                    "type": "string",
                    "source": "html",
                    "selector": "figcaption",
                    "__experimentalRole": "content"
                },
                "title": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "title",
                    "__experimentalRole": "content"
                },
                "href": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "href",
                    "__experimentalRole": "content"
                },
                "rel": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "rel"
                },
                "linkClass": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "class"
                },
                "id": {
                    "type": "number",
                    "__experimentalRole": "content"
                },
                "width": {
                    "type": "number"
                },
                "height": {
                    "type": "number"
                },
                "aspectRatio": {
                    "type": "string"
                },
                "scale": {
                    "type": "string"
                },
                "sizeSlug": {
                    "type": "string"
                },
                "linkDestination": {
                    "type": "string"
                },
                "linkTarget": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "target"
                },
                "ghostkitId": {
                    "type": "string"
                },
                "ghostkitClassname": {
                    "type": "string"
                },
                "ghostkitStyles": {
                    "type": "object"
                },
                "ghostkitSR": {
                    "type": "string"
                },
                "ghostkitCustomCSS": {
                    "type": "string"
                },
                "ghostkitPosition": {
                    "type": "object"
                },
                "ghostkitSpacings": {
                    "type": "object"
                },
                "ghostkitFrame": {
                    "type": "object"
                },
                "lock": {
                    "type": "object"
                },
                "anchor": {
                    "type": "string",
                    "source": "attribute",
                    "attribute": "id",
                    "selector": "*"
                },
                "className": {
                    "type": "string"
                },
                "borderColor": {
                    "type": "string"
                },
                "style": {
                    "type": "object"
                }
            },
            "supports": {
                "anchor": true,
                "color": {
                    "text": false,
                    "background": false
                },
                "filter": {
                    "duotone": true
                },
                "__experimentalBorder": {
                    "color": true,
                    "radius": true,
                    "width": true,
                    "__experimentalSkipSerialization": true,
                    "__experimentalDefaultControls": {
                        "color": true,
                        "radius": true,
                        "width": true
                    }
                }
            }
        },
        {
            "attributes": {
                "align": {
                    "type": "string"
                },
                "url": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "src"
                },
                "alt": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "alt",
                    "default": ""
                },
                "caption": {
                    "type": "string",
                    "source": "html",
                    "selector": "figcaption"
                },
                "title": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "title"
                },
                "href": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "href"
                },
                "rel": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "rel"
                },
                "linkClass": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "class"
                },
                "id": {
                    "type": "number"
                },
                "width": {
                    "type": "number"
                },
                "height": {
                    "type": "number"
                },
                "sizeSlug": {
                    "type": "string"
                },
                "linkDestination": {
                    "type": "string"
                },
                "linkTarget": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "target"
                },
                "ghostkitId": {
                    "type": "string"
                },
                "ghostkitClassname": {
                    "type": "string"
                },
                "ghostkitStyles": {
                    "type": "object"
                },
                "ghostkitSR": {
                    "type": "string"
                },
                "ghostkitCustomCSS": {
                    "type": "string"
                },
                "ghostkitPosition": {
                    "type": "object"
                },
                "ghostkitSpacings": {
                    "type": "object"
                },
                "ghostkitFrame": {
                    "type": "object"
                },
                "lock": {
                    "type": "object"
                },
                "anchor": {
                    "type": "string",
                    "source": "attribute",
                    "attribute": "id",
                    "selector": "*"
                },
                "className": {
                    "type": "string"
                },
                "style": {
                    "type": "object"
                }
            },
            "supports": {
                "anchor": true,
                "color": {
                    "__experimentalDuotone": "img",
                    "text": false,
                    "background": false
                },
                "__experimentalBorder": {
                    "radius": true,
                    "__experimentalDefaultControls": {
                        "radius": true
                    }
                },
                "__experimentalStyle": {
                    "spacing": {
                        "margin": "0 0 1em 0"
                    }
                }
            }
        },
        {
            "attributes": {
                "align": {
                    "type": "string"
                },
                "url": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "src"
                },
                "alt": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "alt",
                    "default": ""
                },
                "caption": {
                    "type": "string",
                    "source": "html",
                    "selector": "figcaption"
                },
                "title": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "title"
                },
                "href": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "href"
                },
                "rel": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "rel"
                },
                "linkClass": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "class"
                },
                "id": {
                    "type": "number"
                },
                "width": {
                    "type": "number"
                },
                "height": {
                    "type": "number"
                },
                "sizeSlug": {
                    "type": "string"
                },
                "linkDestination": {
                    "type": "string"
                },
                "linkTarget": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "target"
                },
                "ghostkitId": {
                    "type": "string"
                },
                "ghostkitClassname": {
                    "type": "string"
                },
                "ghostkitStyles": {
                    "type": "object"
                },
                "ghostkitSR": {
                    "type": "string"
                },
                "ghostkitCustomCSS": {
                    "type": "string"
                },
                "ghostkitPosition": {
                    "type": "object"
                },
                "ghostkitSpacings": {
                    "type": "object"
                },
                "ghostkitFrame": {
                    "type": "object"
                },
                "lock": {
                    "type": "object"
                },
                "anchor": {
                    "type": "string",
                    "source": "attribute",
                    "attribute": "id",
                    "selector": "*"
                },
                "className": {
                    "type": "string"
                }
            },
            "supports": {
                "anchor": true
            }
        },
        {
            "attributes": {
                "url": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "src"
                },
                "alt": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "alt",
                    "default": ""
                },
                "caption": {
                    "type": "array",
                    "source": "children",
                    "selector": "figcaption"
                },
                "href": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "figure > a",
                    "attribute": "href"
                },
                "id": {
                    "type": "number"
                },
                "align": {
                    "type": "string"
                },
                "width": {
                    "type": "number"
                },
                "height": {
                    "type": "number"
                },
                "linkDestination": {
                    "type": "string",
                    "default": "none"
                },
                "ghostkitId": {
                    "type": "string"
                },
                "ghostkitClassname": {
                    "type": "string"
                },
                "ghostkitStyles": {
                    "type": "object"
                },
                "ghostkitSR": {
                    "type": "string"
                },
                "ghostkitCustomCSS": {
                    "type": "string"
                },
                "ghostkitPosition": {
                    "type": "object"
                },
                "ghostkitSpacings": {
                    "type": "object"
                },
                "ghostkitFrame": {
                    "type": "object"
                },
                "lock": {
                    "type": "object"
                },
                "className": {
                    "type": "string"
                }
            }
        },
        {
            "attributes": {
                "url": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "src"
                },
                "alt": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "alt",
                    "default": ""
                },
                "caption": {
                    "type": "array",
                    "source": "children",
                    "selector": "figcaption"
                },
                "href": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "a",
                    "attribute": "href"
                },
                "id": {
                    "type": "number"
                },
                "align": {
                    "type": "string"
                },
                "width": {
                    "type": "number"
                },
                "height": {
                    "type": "number"
                },
                "ghostkitId": {
                    "type": "string"
                },
                "ghostkitClassname": {
                    "type": "string"
                },
                "ghostkitStyles": {
                    "type": "object"
                },
                "ghostkitSR": {
                    "type": "string"
                },
                "ghostkitCustomCSS": {
                    "type": "string"
                },
                "ghostkitPosition": {
                    "type": "object"
                },
                "ghostkitSpacings": {
                    "type": "object"
                },
                "ghostkitFrame": {
                    "type": "object"
                },
                "lock": {
                    "type": "object"
                },
                "className": {
                    "type": "string"
                }
            }
        },
        {
            "attributes": {
                "url": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "src"
                },
                "alt": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "img",
                    "attribute": "alt",
                    "default": ""
                },
                "caption": {
                    "type": "array",
                    "source": "children",
                    "selector": "figcaption"
                },
                "href": {
                    "type": "string",
                    "source": "attribute",
                    "selector": "a",
                    "attribute": "href"
                },
                "id": {
                    "type": "number"
                },
                "align": {
                    "type": "string"
                },
                "width": {
                    "type": "number"
                },
                "height": {
                    "type": "number"
                },
                "ghostkitId": {
                    "type": "string"
                },
                "ghostkitClassname": {
                    "type": "string"
                },
                "ghostkitStyles": {
                    "type": "object"
                },
                "ghostkitSR": {
                    "type": "string"
                },
                "ghostkitCustomCSS": {
                    "type": "string"
                },
                "ghostkitPosition": {
                    "type": "object"
                },
                "ghostkitSpacings": {
                    "type": "object"
                },
                "ghostkitFrame": {
                    "type": "object"
                },
                "lock": {
                    "type": "object"
                },
                "className": {
                    "type": "string"
                }
            }
        }
    ]
}

@t-hamano
Copy link
Contributor

@NicktheGeek Thanks for the reply.

Is it possible to switch to a code editor and send me the code of the broken block? This is markup that includes HTML comments before and after it, and should be data like the following, for example.

<!-- wp:image {"id":13,"width":500,"height":300,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full is-resized">
  <img src="http://localhost:8888/wp-content/uploads/2023/12/test.jpg" alt="" class="wp-image-13" width="500" height="300"/>
</figure>
<!-- /wp:image -->

@NicktheGeek
Copy link

@t-hamano Sure! Here it is

<!-- wp:image {"align":"center","id":3587,"width":200,"height":200,"sizeSlug":"large","linkDestination":"none","style":{"color":{"duotone":["#000000","#ffffff"]},"border":{"width":"0px","style":"none"}},"className":"is-style-rounded ghostkit-custom-1ClGpW","ghostkit":{"id":"1ClGpW","styles":{"padding-bottom":"5%20!important","margin-bottom":"5%20!important"}}} -->
<figure class="wp-block-image aligncenter size-large is-resized has-custom-border is-style-rounded ghostkit-custom-1ClGpW"><img src="{redacted}?w=800" alt="" class="wp-image-3587" style="border-style:none;border-width:0px;width:200px;height:200px"/></figure>
<!-- /wp:image -->

@t-hamano
Copy link
Contributor

@NicktheGeek

Thank you!

Is that markup for an Image block created in WP6.2.3? If so, the width / height attributes should have been applied to the img element in addition to the comment attributes, as shown below.

<!-- wp:image {"id":8,"width":500,"height":300,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full is-resized"><img src="http://localhost:8888/wp-content/uploads/2024/02/test_1.jpg" alt="" class="wp-image-8" width="500" height="300"/></figure>
<!-- /wp:image -->

However, looking at your code, it looks like inline styles are being applied.

Are you extending the Image block with some kind of plugin? In that case, I'm concerned that the plugin has added its own deprecation 🤔

@shanemac10
Copy link

shanemac10 commented Mar 8, 2024

This has escalated to an issue where all of sudden we can't save posts anymore because of this image block issue. We just updated to 6.4.3 and all of a sudden we can't save a ton of our posts, just because the image block had size adjustments that were added before the change over to the new format. Here is an example of one that is broken now...

<!-- wp:image {"align":"center","id":30185,"width":335,"height":217,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image aligncenter size-large is-resized"><img src="https://www.example.com/wp-content/uploads/2022/10/entertainment-center-1024x662.png" alt="" class="wp-image-30185" style="width:335px;height:217px"/></figure>
<!-- /wp:image -->

Please issue a fix for this ASAP

@cartpauj
Copy link

cartpauj commented Mar 8, 2024

Issue still present for us as well:

<!-- wp:image {"align":"center","id":56354,"width":209,"height":163,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image aligncenter size-full is-resized"><img src="https://mysite.com/wp-content/uploads/2023/07/HappyDance.webp" alt="Happy dance!" class="wp-image-56354" style="width:209px;height:163px"/></figure>
<!-- /wp:image -->

@cartpauj
Copy link

fix-block-editor-image-error.zip
Our developer has created this work-around plugin which has resolved this for us in the meantime.

@t-hamano
Copy link
Contributor

@shanemac10 @cartpauj

Looking at your comments, I can see that the image block markup has the following characteristics:

  • Width and height are number attributes
  • Width and height are applied to the img element with inline styles

I looked into the markup in WP6.2.3 and WP6.3.2 in this comment, but the markup above does not apply to either version.

Could you tell which WordPress version the broken image block was created in? Or do you remember the version before updating?

@t-hamano
Copy link
Contributor

Let's keep this issue open until we know what's causing the problem.

@t-hamano t-hamano reopened this Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block [Feature] Block Validation/Deprecation Handling block validation to determine accuracy and deprecation [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants