diff --git a/inc/tag_replacer.php b/inc/tag_replacer.php
index 5a699740..bec94f3c 100644
--- a/inc/tag_replacer.php
+++ b/inc/tag_replacer.php
@@ -76,11 +76,12 @@ public function img_to_video( $image_url, $image_tag, &$content ) {
if ( $this->settings->get( 'img_to_video' ) === 'disabled' ) {
return false;
}
-
if ( $this->is_valid_mimetype_from_url( $image_url, [ 'gif' => false ] ) ) {
return false;
}
-
+ if ( ! $this->is_valid_mimetype_from_url( $image_url ) ) {
+ return false;
+ }
$link_mp4 = apply_filters(
'optml_content_url',
$image_url,
diff --git a/tests/test-video.php b/tests/test-video.php
index ce815423..dc719797 100644
--- a/tests/test-video.php
+++ b/tests/test-video.php
@@ -9,6 +9,17 @@
*/
class Test_Video_Tag extends WP_UnitTestCase {
+ const IMG_TAGS_GIF = '
';
+ const IMG_TAGS_NOT_GIF = '';
+
+ public static $sample_post;
public function setUp() {
parent::setUp();
@@ -16,11 +27,12 @@ public function setUp() {
$settings->update( 'service_data', [
'cdn_key' => 'test123',
'cdn_secret' => '12345',
- 'whitelist' => [ 'encrypted-tbn0.gstatic.com' ],
- 'img_to_video' => 'enabled'
+ 'whitelist' => [ 'example.com' ],
] );
$settings->update( 'lazyload', 'disabled' );
+ $settings->update( 'img_to_video', 'enabled' );
+
Optml_Url_Replacer::instance()->init();
Optml_Tag_Replacer::instance()->init();
@@ -28,28 +40,40 @@ public function setUp() {
self::$sample_post = self::factory()->post->create( [
'post_title' => 'Test post',
- 'post_content' => self::IMG_TAGS
+ 'post_content' => self::IMG_TAGS_GIF
]
);
- self::$sample_attachement = self::factory()->attachment->create_upload_object( OPTML_PATH . 'assets/img/logo.png' );
-
}
- public function test_replace_tag () {
- $image_url = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQK4kPpuaFciC2HriDrMGbBpnbOVMoIwCAa08l5q20ZUOWU067E";
- $img_tag = '
';
- $content = '';
- $this -> assertTrue( Optml_Tag_Replacer::instance()->img_to_video($image_url, $img_tag, $content ));
- $this->assertContains( 'i.optimole.com', $content );
- $this->assertContains( '