Skip to content

Commit 45fa436

Browse files
committed
Enhanced the removal of 'fetchpriority' attributes from lazy-loaded images by using str_ireplace for better handling of various formats.
1 parent bc2e9f2 commit 45fa436

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

inc/lazyload_replacer.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,17 @@ public function lazyload_tag_replace( $new_tag, $original_url, $new_url, $optml_
253253
}
254254
// Remove fetchpriority high attribute when the image is lazyloaded
255255
if ( strpos( $new_tag, 'fetchpriority' ) !== false ) {
256-
$new_tag = preg_replace( '/\s+fetchpriority=(high|[\'"][^\'"]*high[^\'"]*)(?=[\'"\s>]|$)/i', '', $new_tag );
256+
$new_tag = str_ireplace(
257+
[
258+
'fetchpriority=high',
259+
'fetchpriority="high"',
260+
"fetchpriority='high'",
261+
'fetchpriority=\"high\"',
262+
"fetchpriority=\'high\'",
263+
],
264+
'',
265+
$new_tag
266+
);
257267
}
258268

259269
if ( self::instance()->settings->get( 'native_lazyload' ) === 'enabled' ) {

0 commit comments

Comments
 (0)