diff --git a/includes/create-theme/theme-media.php b/includes/create-theme/theme-media.php
index 7e0afa9c..d7a2280a 100644
--- a/includes/create-theme/theme-media.php
+++ b/includes/create-theme/theme-media.php
@@ -94,7 +94,10 @@ public static function get_media_absolute_urls_from_template( $template ) {
public static function make_relative_media_url( $absolute_url ) {
if ( ! empty( $absolute_url ) && CBT_Theme_Utils::is_absolute_url( $absolute_url ) ) {
$folder_path = self::get_media_folder_path_from_url( $absolute_url );
- return '' . $folder_path . basename( $absolute_url );
+ if ( is_child_theme() ) {
+ return '' . $folder_path . basename( $absolute_url );
+ }
+ return '' . $folder_path . basename( $absolute_url );
}
return $absolute_url;
}
diff --git a/tests/test-theme-media.php b/tests/test-theme-media.php
index ee96ffd2..0671a6d6 100644
--- a/tests/test-theme-media.php
+++ b/tests/test-theme-media.php
@@ -15,7 +15,7 @@ public function test_make_images_block_local() {
// The image should be replaced with a relative URL
$this->assertStringNotContainsString( 'http://example.com/image.jpg', $new_template->content );
- $this->assertStringContainsString( 'get_stylesheet_directory_uri', $new_template->content );
+ $this->assertStringContainsString( 'get_template_directory_uri', $new_template->content );
$this->assertStringContainsString( '/assets/images', $new_template->content );
}
@@ -35,7 +35,7 @@ public function test_make_cover_block_local() {
// The image should be replaced with a relative URL
$this->assertStringNotContainsString( 'http://example.com/image.jpg', $new_template->content );
- $this->assertStringContainsString( 'get_stylesheet_directory_uri', $new_template->content );
+ $this->assertStringContainsString( 'get_template_directory_uri', $new_template->content );
$this->assertStringContainsString( '/assets/images', $new_template->content );
}
@@ -56,7 +56,7 @@ public function test_template_with_media_correctly_prepared() {
$this->assertContains( 'http://example.com/image.jpg', $new_template->media );
// The pattern is correctly encoded
- $this->assertStringContainsString( 'pattern );
+ $this->assertStringContainsString( 'pattern );
}
@@ -77,7 +77,7 @@ public function test_make_group_block_local() {
$this->assertContains( 'http://example.com/image.jpg', $new_template->media );
// The pattern is correctly encoded
- $this->assertStringContainsString( '{"backgroundImage":{"url":"/assets/images/image.jpg"', $new_template->pattern );
+ $this->assertStringContainsString( '{"backgroundImage":{"url":"/assets/images/image.jpg"', $new_template->pattern );
}
}