diff --git a/admin/create-theme/theme-media.php b/admin/create-theme/theme-media.php index 23b9ffe4..71298877 100644 --- a/admin/create-theme/theme-media.php +++ b/admin/create-theme/theme-media.php @@ -73,6 +73,13 @@ public static function get_media_absolute_urls_from_template( $template ) { } } } + + // Gets the absolute URLs of background images in these blocks + if ( 'core/group' === $block['blockName'] ) { + if ( isset( $block['attrs']['style']['background']['backgroundImage']['url'] ) && Theme_Utils::is_absolute_url( $block['attrs']['style']['background']['backgroundImage']['url'] ) ) { + $media[] = $block['attrs']['style']['background']['backgroundImage']['url']; + } + } } return $media; diff --git a/tests/test-theme-media.php b/tests/test-theme-media.php index fd54f747..26b40e79 100644 --- a/tests/test-theme-media.php +++ b/tests/test-theme-media.php @@ -60,4 +60,24 @@ public function test_template_with_media_correctly_prepared() { } + public function test_make_group_block_local() { + $template = new stdClass(); + $template->slug = 'test-template'; + $template->content = ' + +
+ + '; + $new_template = Theme_Templates::prepare_template_for_export( $template ); + + // Content should be replaced with a pattern block + $this->assertStringContainsString( '