-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Comments
Hi, |
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. |
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 VersionI am currently using WordPress 6.7. Folder Structure for ThemesHere is my folder structure for themes: Child Theme DetailsFile: /*
Theme Name: Twenty Twenty Four Child
Template: twentytwentyfour
Description: A child theme for Twenty Twenty Four theme
*/ File: {
"$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 Demonstrationvideo demonstrating the output: Screen.Recording.2024-11-18.at.3.11.52.PM.mov |
The issue is with the aspect ratio option in the Image Block cropping tool @Infinite-Null, not the sidebar selector. Have a look at Marc's video. |
Hi @stian-overasen Thank you for clarifying this! I attempted the same with the image block, and while the issue occurs, I couldn’t find any errors in the console. Here is video for same: Screen.Recording.2024-11-22.at.2.18.54.PM.mov |
I found the bug @Infinite-Null @marcwieland95 In the Luckily this a easy fix by changing line 114 in aspect-ratio-dropdown.js from: aspectRatios={ themeRatios } to: aspectRatios={ themeRatios.map( presetRatioAsNumber ) } I'll do a PR. Video showing the bug when selecting a theme ratio:Screen.Recording.2024-11-26.at.08.mp4 |
@fabiankaegy, do you mind having a look at the proposed solution? |
Hi, |
Definitely still a problem. |
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:
Step-by-step reproduction instructions
theme.json
(I'm adjusting the config of thetheme.json
in the child-theme)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.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
The text was updated successfully, but these errors were encountered: