Make WordPress Core

Changeset 58242


Ignore:
Timestamp:
05/30/2024 03:08:31 AM (4 months ago)
Author:
isabel_brison
Message:

Editor: add aspect ratio presets support.

Enables customizing the list of aspect ratio options available through theme.json.

Props fabiankaegy, isabel_brison, swissspidy.

Location:
trunk/src/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json.php

    r58241 r58242  
    124124     * @since 6.2.0 Added 'shadow' presets.
    125125     * @since 6.3.0 Replaced value_func for duotone with `null`. Custom properties are handled by class-wp-duotone.php.
     126     * @since 6.6.0 Added the `dimensions.aspectRatios` & `dimensions.defaultAspectRatios` preset.
    126127     * @var array
    127128     */
    128129    const PRESETS_METADATA = array(
     130        array(
     131            'path'              => array( 'dimensions', 'aspectRatios' ),
     132            'prevent_override'  => array( 'dimensions', 'defaultAspectRatios' ),
     133            'use_default_names' => false,
     134            'value_key'         => 'ratio',
     135            'css_vars'          => '--wp--preset--aspect-ratio--$slug',
     136            'classes'           => array(),
     137            'properties'        => array( 'aspect-ratio' ),
     138        ),
    129139        array(
    130140            'path'              => array( 'color', 'palette' ),
     
    366376     * @since 6.5.0 Added support for `layout.allowCustomContentAndWideSize`,
    367377     *              `background.backgroundSize` and `dimensions.aspectRatio`.
     378     * @since 6.6.0 Added support for `dimensions.aspectRatios` and `dimensions.defaultAspectRatios`.
    368379     * @var array
    369380     */
     
    400411        'custom'                        => null,
    401412        'dimensions'                    => array(
    402             'aspectRatio' => null,
    403             'minHeight'   => null,
     413            'aspectRatio'         => null,
     414            'aspectRatios'        => null,
     415            'defaultAspectRatios' => null,
     416            'minHeight'           => null,
    404417        ),
    405418        'layout'                        => array(
  • trunk/src/wp-includes/theme-i18n.json

    r54272 r58242  
    3535                {
    3636                    "name": "Space size name"
     37                }
     38            ]
     39        },
     40        "dimensions": {
     41            "aspectRatios": [
     42                {
     43                    "name": "Aspect ratio name"
    3744                }
    3845            ]
  • trunk/src/wp-includes/theme.json

    r57885 r58242  
    190190            ],
    191191            "text": true
     192        },
     193        "dimensions": {
     194            "defaultAspectRatios": true,
     195            "aspectRatios": [
     196                {
     197                    "name": "Square - 1:1",
     198                    "slug": "square",
     199                    "ratio": "1"
     200                },
     201                {
     202                    "name": "Standard - 4:3",
     203                    "slug": "4-3",
     204                    "ratio": "4/3"
     205                },
     206                {
     207                    "name": "Portrait - 3:4",
     208                    "slug": "3-4",
     209                    "ratio": "3/4"
     210                },
     211                {
     212                    "name": "Classic - 3:2",
     213                    "slug": "3-2",
     214                    "ratio": "3/2"
     215                },
     216                {
     217                    "name": "Classic Portrait - 2:3",
     218                    "slug": "2-3",
     219                    "ratio": "2/3"
     220                },
     221                {
     222                    "name": "Wide - 16:9",
     223                    "slug": "16-9",
     224                    "ratio": "16/9"
     225                },
     226                {
     227                    "name": "Tall - 9:16",
     228                    "slug": "9-16",
     229                    "ratio": "9/16"
     230                }
     231            ]
    192232        },
    193233        "shadow": {
Note: See TracChangeset for help on using the changeset viewer.