Skip to content

Gallery block: custom list of aspect ratio not working #72671

@bph

Description

@bph

Description

With the aspect ratio now available for the Gallery block, it should be controllable via theme.json for this core block according to the theme.json schema.

It is my understanding:

  • "aspectRatio": true enables the feature
  • "defaultAspectRatios": false disables the default list
  • "aspectRatios" [ ] provides a custom list of aspect ratios.

However when I try to enable the feature and provide a shortened list of aspect ratios it doesn't display in the settings tab of the gallery block.

Step-by-step reproduction instructions

  • Add below code snippet to your theme.json's settings section on your test site.
  • Add a gallery block to a post or page
  • Open the block sidebar on the settings tab
  • The aspect ratio drop-down list doesn't appear.

Screenshots, screen recording, code snippet

"blocks":{
	"core/gallery":{
		"dimensions":{
			"defaultAspectRatios":false,
			"aspectRatio": true,
			"aspectRatios": [
						{
				"name": "Square - 1:1",
				"slug": "square",
				"ratio": "1"
				},
				{
				"name": "Wide - 16:9",
				"slug": "16-9",
				"ratio": "16/9"
				},
				{
				"name": "Tall - 9:16",
				"slug": "9-16",
				"ratio": "9/16"
				}
			]
		}			
	}
}

Environment info

WordPress 6.8.3
Gutenberg 21.9

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] GalleryAffects the Gallery Block - used to display groups of images[Status] Needs More InfoFollow-up required in order to be actionable.[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    Status

    📥 Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions