Skip to content

Commit

Permalink
Merge pull request #147 from Codeinwp/fix/lazyload_query_urls
Browse files Browse the repository at this point in the history
fix: lazyload query urls part of #145
  • Loading branch information
selul authored Sep 23, 2019
2 parents eea6202 + e7e1559 commit f450143
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions inc/lazyload_replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tests/test-lazyload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<img src="https://example.org/photos/814499/pexels-photo-814499.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" alt="">';
$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);
}

}

0 comments on commit f450143

Please sign in to comment.