Skip to content

Image block: change to custom style selector hierarchy breaks frontend display on classic themes #39297

@glendaviesnz

Description

@glendaviesnz

Description

The change to remove the extra alignment wrapper on image blocks breaks some image styling options in the frontend for non theme.json themes when an Image block has both alignment and a custom style applied.

The change was designed to be backwards compatible with classic themes by adding the wrapper back in the frontend for these themes. However, this change only adds the wp-block-image class to this wrapper, and some themes and plugins rely on any custom classes also being applied to the same element, eg. .wp-block-image.is-style-rounded.

For themes relying on the core css for the is-style-rounded style this has been fixed here.

The TwentyTwentyOne theme has its own custom image styles that are broken by this change, and it appears that there are approx 12 plugins and 59 themes that might be affected in the public repo.

Step-by-step reproduction instructions

  1. With TwentyTwentyOne theme selected add an Image
  2. Apply right alignment and one of the custom Borders or Frame style
  3. Save post and view in the frontend and notice that the styles do not display

Screenshots, screen recording, code snippet

image-style-bug.mp4

Environment info

No response

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

No one assigned

    Labels

    [Block] ImageAffects the Image Block[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions