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

Add aspect ratio presets support via theme.json #6567

Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/wp-includes/class-wp-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,19 @@ class WP_Theme_JSON {
* `prevent_override` value for `color.duotone` to use `color.defaultDuotone`.
* @since 6.2.0 Added 'shadow' presets.
* @since 6.3.0 Replaced value_func for duotone with `null`. Custom properties are handled by class-wp-duotone.php.
* @since 6.6.0 Added the `dimensions.aspectRatios` preset.
* @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' ),
Expand Down Expand Up @@ -390,8 +400,10 @@ class WP_Theme_JSON {
),
'custom' => null,
'dimensions' => array(
'aspectRatio' => null,
'minHeight' => null,
'aspectRatio' => null,
'aspectRatios' => null,
'defaultAspectRatios' => null,
'minHeight' => null,
fabiankaegy marked this conversation as resolved.
Show resolved Hide resolved
),
'layout' => array(
'contentSize' => null,
Expand Down
7 changes: 7 additions & 0 deletions src/wp-includes/theme-i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
}
]
},
"dimensions": {
"aspectRatios": [
{
"Name": "Aspect ratio name"
}
]
},
"blocks": {
"*": {
"typography": {
Expand Down
40 changes: 40 additions & 0 deletions src/wp-includes/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,46 @@
],
"text": true
},
"dimensions": {
"defaultAspectRatios": true,
"aspectRatios": [
{
"name": "Square - 1:1",
"slug": "square",
"ratio": "1"
},
{
"name": "Standard - 4:3",
"slug": "4-3",
"ratio": "4/3"
},
{
"name": "Portrait - 3:4",
"slug": "3-4",
"ratio": "3/4"
},
{
"name": "Classic - 3:2",
"slug": "3-2",
"ratio": "3/2"
},
{
"name": "Classic Portrait - 2:3",
"slug": "2-3",
"ratio": "2/3"
},
{
"name": "Wide - 16:9",
"slug": "16-9",
"ratio": "16/9"
},
{
"name": "Tall - 9:16",
"slug": "9-16",
"ratio": "9/16"
}
]
},
"shadow": {
"defaultPresets": true,
"presets": [
Expand Down
Loading