Skip to content

Commit

Permalink
Modify regex to capture right element
Browse files Browse the repository at this point in the history
  • Loading branch information
jeawhanlee committed Apr 10, 2024
1 parent ca50f74 commit 86c95b1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion inc/Engine/Media/AboveTheFold/Frontend/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private function set_fetchpriority( $lcp, string $html ): string {

$url = preg_quote( $lcp->src, '/' );
$html = preg_replace_callback(
'#<img(?:[^>]*?\s+src=["\']' . $url . '["\'][^>]*?|[^>]*?)>#',
'#<img(?:[^>]*?\s+)?src=["\']' . $url . '["\'](?:\s+[^>]*?)?>#',
function ( $matches ) {
// Check if the fetchpriority attribute already exists.
if ( preg_match( '/fetchpriority\s*=\s*[\'"]([^\'"]+)[\'"]/i', $matches[0] ) ) {
Expand Down

0 comments on commit 86c95b1

Please sign in to comment.