From e7e1559986d35344a8a17c8e9573296753fe4a25 Mon Sep 17 00:00:00 2001 From: Bogdan Preda Date: Mon, 23 Sep 2019 17:19:24 +0300 Subject: [PATCH] fix: lazyload query urls part of #145 --- composer.json | 2 +- inc/lazyload_replacer.php | 2 ++ tests/test-lazyload.php | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c093d4be..f92a2f86 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "format": "phpcbf --standard=phpcs.xml --report-summary --report-source", "phpcs": "phpcs --standard=phpcs.xml --extensions=php -s", "phpmd": "phpmd inc text phpmd.xml", - "test": "phpunit --confirguration=phpunit.xml", + "test": "phpunit --configuration=phpunit.xml", "lint": "composer run-script phpcs" }, "require": { diff --git a/inc/lazyload_replacer.php b/inc/lazyload_replacer.php index 32a8cde6..54058c10 100644 --- a/inc/lazyload_replacer.php +++ b/inc/lazyload_replacer.php @@ -200,6 +200,8 @@ public function can_lazyload_for( $url, $tag = '' ) { if ( false === Optml_Filters::should_do_image( $url, self::$filters[ Optml_Settings::FILTER_TYPE_LAZYLOAD ][ Optml_Settings::FILTER_FILENAME ] ) ) { return false; } + $url = strtok( $url, '?' ); + $type = wp_check_filetype( basename( $url ), Optml_Config::$extensions diff --git a/tests/test-lazyload.php b/tests/test-lazyload.php index 93f913fe..103c448d 100644 --- a/tests/test-lazyload.php +++ b/tests/test-lazyload.php @@ -255,4 +255,12 @@ public function test_lazyload_json_data_disabled() { $this->assertEquals( 2, substr_count( $replaced_content2, '/http:\/\/example.org' ) ); } + public function test_should_replace_query_string_url() { + $content = ''; + $replaced_content = Optml_Manager::instance()->replace_content($content); + $this->assertContains('i.optimole.com', $replaced_content); + $this->assertContains('data-opt-src', $replaced_content); + $this->assertContains('example.org', $replaced_content); + } + }