diff --git a/inc/manager.php b/inc/manager.php index 0be17b58..9e7886d9 100644 --- a/inc/manager.php +++ b/inc/manager.php @@ -481,7 +481,7 @@ public function process_urls_from_content( $html ) { * @return array */ public function extract_image_urls_from_content( $content ) { - $regex = '/(?:http(?:s?):)(?:[\/\\\\|.|\w|\s|-])*\.(?:' . implode( '|', array_keys( Optml_Config::$extensions ) ) . ')(?:\?{1}[\w|=|&|\-|\.|:|;]*)?/'; + $regex = '/((?:http(?:s?):)(?:[\/\\\\|.|\w|\s|-])*\.(?:' . implode( '|', array_keys( Optml_Config::$extensions ) ) . ')(?:\?{1}[\w|=|&|\-|\.|:|;]*)?)|((?:[\/\\\\|.|\w|\s|-])*\.(?:' . implode( '|', array_keys( Optml_Config::$extensions ) ) . ')(?:\?{1}[\w|=|&|\-|\.|:|;]*)?)/'; preg_match_all( $regex, $content, diff --git a/tests/test-background-image.php b/tests/test-background-image.php new file mode 100644 index 00000000..6aa4658e --- /dev/null +++ b/tests/test-background-image.php @@ -0,0 +1,51 @@ + '; + + + public static $sample_post; + + public function setUp() + { + + parent::setUp(); + $settings = new Optml_Settings(); + $settings->update('service_data', [ + 'cdn_key' => 'test123', + 'cdn_secret' => '12345', + 'whitelist' => ['example.com'], + + ]); + $settings->update('lazyload', 'disabled'); + $settings->update('img_to_video', 'enabled'); + + + Optml_Url_Replacer::instance()->init(); + Optml_Tag_Replacer::instance()->init(); + Optml_Manager::instance()->init(); + + self::$sample_post = self::factory()->post->create([ + 'post_title' => 'Test post', + 'post_content' => self::IMG_TAGS_GIF + ] + ); + } + + public function test_should_replace_tag() + { + + $replaced_content = Optml_Manager::instance()->replace_content(self::IMG_TAGS_GIF); + $this->assertContains('i.optimole.com', $replaced_content); + } +} +