diff --git a/packages/block-library/src/cover/index.php b/packages/block-library/src/cover/index.php index 515f53b7c64d7b..791587c05adb6a 100644 --- a/packages/block-library/src/cover/index.php +++ b/packages/block-library/src/cover/index.php @@ -47,18 +47,14 @@ function render_block_core_cover( $attributes, $content ) { } $current_featured_image = get_the_post_thumbnail_url(); - $styles = 'background-image:url(' . esc_url( $current_featured_image ) . '); '; - - if ( isset( $attributes['minHeight'] ) ) { - $height_unit = empty( $attributes['minHeightUnit'] ) ? 'px' : $attributes['minHeightUnit']; - $height = " min-height:{$attributes['minHeight']}{$height_unit}"; - - $styles .= $height; - } - $processor = new WP_HTML_Tag_Processor( $content ); $processor->next_tag(); - $processor->set_attribute( 'style', $styles ); + + $styles = $processor->get_attribute( 'style' ); + $merged_styles = ! empty( $styles ) ? $styles . ';' : ''; + $merged_styles .= 'background-image:url(' . esc_url( $current_featured_image ) . ');'; + + $processor->set_attribute( 'style', $merged_styles ); $content = $processor->get_updated_html(); } diff --git a/phpunit/blocks/render-block-cover-test.php b/phpunit/blocks/render-block-cover-test.php index 753aa14f2fe4db..8a249b2c119f01 100644 --- a/phpunit/blocks/render-block-cover-test.php +++ b/phpunit/blocks/render-block-cover-test.php @@ -15,7 +15,7 @@ class Tests_Blocks_Render_Cover extends WP_UnitTestCase { /** * Post object. * - * @var array + * @var object */ protected static $post; @@ -76,7 +76,7 @@ public function test_gutenberg_render_block_core_cover() { 'minHeight' => '100px', ); - $content = '