diff --git a/src/Dependencies/RocketLazyload/Image.php b/src/Dependencies/RocketLazyload/Image.php index bf09538..02e8528 100644 --- a/src/Dependencies/RocketLazyload/Image.php +++ b/src/Dependencies/RocketLazyload/Image.php @@ -256,11 +256,11 @@ public function lazyloadPictures( $html, $buffer ) { continue; } + $lazy_sources = 0; + if ( preg_match_all( '#\s.+)>#iUs', $picture['sources'], $sources, PREG_SET_ORDER ) ) { $sources = array_unique( $sources, SORT_REGULAR ); - $lazy_sources = 0; - foreach ( $sources as $source ) { $lazyload_srcset = preg_replace( '/([\s"\'])srcset/i', '\1data-lazy-srcset', $source[0] ); $html = str_replace( $source[0], $lazyload_srcset, $html );