-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add aspect ratio presets support via theme.json #47271
Changes from all commits
90e2234
7a7c0be
d84e302
5d3fb1e
da7bd3b
106a1ee
a4d19db
319ff9a
2c5c277
b994e40
d979582
4a5504b
f6af1ac
84cb3b8
1c620c9
6e0af44
2805bd9
a98264b
5047066
0706296
0669c67
db32e98
d735e52
001391b
18c2045
7f6223f
8a3088c
8496552
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,9 +123,19 @@ class WP_Theme_JSON_Gutenberg { | |
* @since 6.0.0 Replaced `override` with `prevent_override` and updated the | ||
* `prevent_override` value for `color.duotone` to use `color.defaultDuotone`. | ||
* @since 6.2.0 Added 'shadow' presets. | ||
* @since 6.6.0 Added `aspectRatios`. | ||
* @var array | ||
*/ | ||
const PRESETS_METADATA = array( | ||
array( | ||
'path' => array( 'dimensions', 'aspectRatios' ), | ||
'prevent_override' => array( 'dimensions', 'defaultAspectRatios' ), | ||
'use_default_names' => false, | ||
'value_key' => 'ratio', | ||
'css_vars' => '--wp--preset--aspect-ratio--$slug', | ||
'classes' => array(), | ||
'properties' => array( 'aspect-ratio' ), | ||
), | ||
array( | ||
'path' => array( 'color', 'palette' ), | ||
'prevent_override' => array( 'color', 'defaultPalette' ), | ||
|
@@ -397,8 +407,10 @@ class WP_Theme_JSON_Gutenberg { | |
), | ||
'custom' => null, | ||
'dimensions' => array( | ||
'aspectRatio' => null, | ||
'minHeight' => null, | ||
'aspectRatio' => null, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated: I noticed that you can't disable aspect ration for Image block using this setting. cc @draganescu There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was it supposed to be 😄 What is the expected behaviour here:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The initial Setting it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, indeed setting to false hides this dimension tool from the cover block but it does not hide it from the image block. The reason is that the cover block uses the supports while the image block plops the control in the inspector. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I'm aware of that. Still, the behavior should be consistent. @fabiankaegy, do you mind creating an issue for the Image and Featured Image block follow-ups we discussed in Slack? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I knew that, you told me where to look! 😂 I mentioned here for archaeology reasons. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created a follow up issue for the aspect ratio block support cleanup: #61432 |
||
'aspectRatios' => null, | ||
'defaultAspectRatios' => null, | ||
'minHeight' => null, | ||
), | ||
'layout' => array( | ||
'contentSize' => null, | ||
|
@@ -483,7 +495,7 @@ class WP_Theme_JSON_Gutenberg { | |
* updated `blockGap` to be allowed at any level. | ||
* @since 6.2.0 Added `outline`, and `minHeight` properties. | ||
* @since 6.6.0 Added `background` sub properties to top-level only. | ||
* | ||
* @since 6.6.0 Added `dimensions.aspectRatio`. | ||
* @var array | ||
*/ | ||
const VALID_STYLES = array( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to add just the settings for the image block aspect ratio tool in this PR, but it seems that the UI is coupled to the preset generation. So, even though this generated CSS isn't used, it had to be added to get the UI to work.
I don't think it's too big of a deal since we would add those presets for the
aspect-ratio
property anyway for the featured image in a follow-up, but it certainly surprised me that the code was coupled this way.