From 7e14457ce2ec28ed2cbd8756ca85c17051284d5c Mon Sep 17 00:00:00 2001 From: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:49:07 +1100 Subject: [PATCH] Skip output of has-aspect-ratio if value isn't set --- lib/block-supports/dimensions.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/block-supports/dimensions.php b/lib/block-supports/dimensions.php index 6aeaed2523871..1980faba27817 100644 --- a/lib/block-supports/dimensions.php +++ b/lib/block-supports/dimensions.php @@ -132,6 +132,12 @@ function gutenberg_render_dimensions_support( $block_content, $block ) { if ( ! empty( $styles['classnames'] ) ) { foreach ( explode( ' ', $styles['classnames'] ) as $class_name ) { + if ( + str_contains( $class_name, 'aspect-ratio' ) && + ! isset( $block_attributes['style']['dimensions']['aspectRatio'] ) + ) { + continue; + } $tags->add_class( $class_name ); } }