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

$lazy_sources triggers a undefined variable PHP notice #123

Open
DahmaniAdame opened this issue Apr 1, 2021 · 1 comment · May be fixed by #125
Open

$lazy_sources triggers a undefined variable PHP notice #123

DahmaniAdame opened this issue Apr 1, 2021 · 1 comment · May be fixed by #125
Assignees
Labels

Comments

@DahmaniAdame
Copy link

DahmaniAdame commented Apr 1, 2021

Undefined variable: lazy_sources in Image.php on line 273

We need to either move $lazy_sources = 0; outside of if ( preg_match_all()){} or move if ( 0 === $lazy_sources ){} inside of if ( preg_match_all()){} (like we do on WP Rocket).

if ( preg_match_all( '#<source(?<atts>\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 );
unset( $lazyload_srcset );
$lazy_sources++;
}
}
if ( 0 === $lazy_sources ) {
continue;
}

@DahmaniAdame
Copy link
Author

@remyperona remyperona self-assigned this Oct 1, 2021
@remyperona remyperona linked a pull request Oct 1, 2021 that will close this issue
@remyperona remyperona added the bug label Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants