Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support background css property #91

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use wp_strip_all_tags instead of strip_tags
  • Loading branch information
engahmeds3ed committed Dec 25, 2020
commit 252aae9759b5909ccffcc11cb3b12e04b83df4ca
2 changes: 1 addition & 1 deletion src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function lazyloadBackgroundImages( $html, $buffer ) {

$url['url'] = esc_url(
trim(
strip_tags(
wp_strip_all_tags(
html_entity_decode(
$url['url'],
ENT_QUOTES | ENT_HTML5
Expand Down
12 changes: 12 additions & 0 deletions tests/Unit/Image/TestLazyloadBackgroundImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,22 @@ public function testShouldReturnSameWhenNoBackgroundImage() {

public function testShouldReturnBackgroundImagesLazyloaded() {
Functions\when('esc_attr')->returnArg();

Functions\expect('esc_url')->andReturnUsing( function ( $url ){
return str_replace(['"', "'"], [""", "'"], $url );
} );

Functions\expect('wp_strip_all_tags')->andReturnUsing( function ( $string, $remove_breaks = false ){
$string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
$string = strip_tags( $string );

if ( $remove_breaks ) {
$string = preg_replace( '/[\r\n\t ]+/', ' ', $string );
}

return trim( $string );
} );

$original = \file_get_contents( RLL_COMMON_TESTS_ROOT . '/fixtures/Image/bgimages.html');
$expected = \file_get_contents( RLL_COMMON_TESTS_ROOT . '/fixtures/Image/bgimageslazyloaded.html');

Expand Down