Skip to content

Custom aspect-ratio within theme.json not working #66077

@mawiswiss

Description

@mawiswiss

Description

I'm adding a custom aspect ratio on ann image block within the theme.json of my child theme. It gets added in Gutenberg but breaks things in the editor (see video below).

In the console the following error is thrown after selecting a custom aspect ratio:

react-dom.js?ver=18:1 Warning: `NaN` is an invalid value for the `height` css style property.

Step-by-step reproduction instructions

theme.json (I'm adjusting the config of the theme.json in the child-theme)

"core/image": {
  "dimensions": {
      "aspectRatios": [
          {
              "name": "Extra Wide - 2:1",
              "ratio": "2/1",
              "slug": "2-1"
          },
          {
              "name": "Cinema - 21:9",
              "ratio": "21/9",
              "slug": "21-9"
          }
      ]
  }
}

I am then trying to set the new aspect ratio in Gutenberg. The default can be set and the view is adjusted. The theme aspect ratio falls back to the full image and breaks further adjustments in the other options (can't set the focus area of the image for example).

Screenshots, screen recording, code snippet

CleanShot.2024-10-12.at.11.29.06.mp4

Environment info

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

Labels

Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions