Make WordPress Core

Opened 5 months ago

Closed 5 months ago

Last modified 4 months ago

#60365 closed enhancement (fixed)

Introduce dimensions.aspectRatio block support

Reported by: andrewserong's profile andrewserong Owned by: isabel_brison's profile isabel_brison
Milestone: 6.5 Priority: normal
Severity: normal Version: 6.5
Component: Editor Keywords: gutenberg-merge has-patch has-unit-tests add-to-field-guide
Focuses: Cc:


In the Gutenberg plugin, an aspect ratio block support feature was added, with support for both Group and Cover blocks. It would be good to backport this feature for the WP 6.5 release.

While the feature is spread across JS and PHP code, it should be possible to land most of the PHP implementation in advance of the JS packages update for core.

The original feature landed in Gutenberg in the following PR:

Change History (6)

This ticket was mentioned in PR #5963 on WordPress/wordpress-develop by @andrewserong.

5 months ago

  • Keywords has-patch has-unit-tests added

Backport the aspect ratio block support feature from the Gutenberg plugin, that originally landed in:

Note this PR backports the PHP parts of the block support. This can be safely done prior to the JS packages landing for core, as the UI for the feature will not be exposed until the JS packages are updated.

Testing this PR manually in wordpress-develop is possible via the following steps:

  • Update the Group block's block.json file to include dimensions: { aspectRatio: true } under the supports key. I.e. the dimensions support will now look like:
		"dimensions": {
			"aspectRatio": true,
			"minHeight": true
  • Skip the block.json cache so the changes to the block.json file are picked up. A quick way is to comment out the following lines:

  • In a post or page add the following markup that contains a Group block with an aspect-ratio set:
<div class="wp-block-group has-background" style="background-color:#f0d1d1">
<p>A group block</p>

  • Note: at this stage you won't yet see the aspect ratio rendered in the editor — this is to be expected as JS rendering will only happen once the JS packages are updated.
  • Save the post or page and load the post on the site frontend. You should see that the aspect ratio rules are output for this block, along with a min-height:unset rule:

Trac ticket:

#2 @isabel_brison
5 months ago

  • Owner set to isabel_brison
  • Resolution set to fixed
  • Status changed from new to closed

In 57491:

Editor: introduce dimensions.aspectRatio block support.

Adds front end rendering logic for the dimensions.aspectRatio block support as well as the required logic in WP_Theme_JSON and the style engine.

Props andrewserong.
Fixes #60365.

@isabel_brison commented on PR #5963:

5 months ago

Committed in r57491.

@andrewserong commented on PR #5963:

5 months ago

Wonderful, thank you @tellthemachines! 🙇

#5 @stevenlinx
4 months ago

  • Keywords add-to-field-guide added

This ticket was mentioned in Slack in #core-test by oglekler. View the logs.

4 months ago

Note: See TracTickets for help on using tickets.