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

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

Open
2 tasks done
marcwieland95 opened this issue Oct 12, 2024 · 3 comments
Open
2 tasks done

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

marcwieland95 opened this issue Oct 12, 2024 · 3 comments
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended

Comments

@marcwieland95
Copy link

marcwieland95 commented Oct 12, 2024

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
@marcwieland95 marcwieland95 added the [Type] Bug An existing feature does not function as intended label Oct 12, 2024
@miminari miminari added Needs Testing Needs further testing to be confirmed. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Oct 16, 2024
Copy link

Hi,
This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.
Thanks for helping out.

@github-actions github-actions bot added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Nov 16, 2024
@marcwieland95
Copy link
Author

I was just testing it with WordPress 6.7 and the latest Gutenberg plugin version. Still the same NaN error in the console on custom aspect ratio.

@github-actions github-actions bot removed the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Nov 17, 2024
@Infinite-Null
Copy link
Contributor

Hi @marcwieland95,

Thank you for highlighting this issue. I attempted to reproduce it but was unable to do so. Below are the details of my setup and the steps I followed:

WordPress Version

I am currently using WordPress 6.7.

Folder Structure for Themes

Here is my folder structure for themes:

Image

Child Theme Details

File: themes/twentytwentyfourchild/style.css:

/*
Theme Name: Twenty Twenty Four Child
Template: twentytwentyfour
Description: A child theme for Twenty Twenty Four theme
*/

File: themes/twentytwentyfourchild/theme.json:

{
    "$schema": "https://schemas.wp.org/trunk/theme.json",
    "version": 3,
    "settings": {
        "blocks": {
            "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"
                        }
                    ]
                }
            }
        }
    }
}

Video Demonstration

video demonstrating the output:

Screen.Recording.2024-11-18.at.3.11.52.PM.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants