Skip to content

Instantly share code, notes, and snippets.

@joemaller
Created March 21, 2025 18:49
Show Gist options
  • Save joemaller/c709ce06129ed3eab7cffc60a93ffc88 to your computer and use it in GitHub Desktop.
Save joemaller/c709ce06129ed3eab7cffc60a93ffc88 to your computer and use it in GitHub Desktop.
Brief notes on setting custom Aspect Ratios for the WordPress Block Editor

WordPress 6.6 introduced support for custom Aspect Ratios for image blocks. Image Aspect Ratio options can be configured in the WordPress Block Editor by providing a list in the settings.dimensions object.

There's no easy way to remove individual aspect ratios from the list. The only options are to extend the existing list or fully replace it.

So, something like the following will produce a menu with 12 Aspect Ratio choices.

{
  "$schema": "https://schemas.wp.org/trunk/theme.json",
  "version": 3,
  "settings": {
    "dimensions": {
      "aspectRatio": true,
      "aspectRatios": [
        {
          "name": "Golden Ratio Wide - 1.618:1",
          "slug": "1618-1",
          "ratio": "1.618/1"
        },
        {
          "name": "Golden Ratio Tall - 1:1.618",
          "slug": "1-1618",
          "ratio": "1/1.618"
        },
        {
          "name": "Wide - 2:1",
          "slug": "2-1",
          "ratio": "2/1"
        },
        {
          "name": "Tall - 1:2",
          "slug": "1-2",
          "ratio": "1/2"
        }
      ],
      "defaultAspectRatios": true
    }
}

image

Switching defaultAspectRatios to false would only offer the four specified options:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment