Lazy load

chris37

Well-Known Member
Anybody know how to disable the inbuild lazy load of wordpress 5.5 ...?

Is not working nice is my site and I can not use and the one i use before , because of conflict between them.

Is new update and I did find anything in the web.
 

Mar

Moderator
Anybody know how to disable the inbuild lazy load of wordpress 5.5 ...?
Add this snippet to functions.php:

function disable_template_image_lazy_loading( $default, $tag_name, $context ) {
if ( 'img' === $tag_name && 'wp_get_attachment_image' === $context ) {
return false;
}
return $default;
}
add_filter(
'wp_lazy_loading_enabled',
'disable_template_image_lazy_loading',
10,
3
);
 

daniel-97

Well-Known Member
Add this snippet to functions.php:

function disable_template_image_lazy_loading( $default, $tag_name, $context ) {
if ( 'img' === $tag_name && 'wp_get_attachment_image' === $context ) {
return false;
}
return $default;
}
add_filter(
'wp_lazy_loading_enabled',
'disable_template_image_lazy_loading',
10,
3
);
In my files, the lazy load is not mentioned in functions.php file, it has a separate file which is "class-wp-metadata-lazyloader.php"

Do I still add the code above to my functions.php file or to "class-wp-metadata-lazyloader.php" file"?

Thanks in advance!
 

Mar

Moderator
In my files, the lazy load is not mentioned in functions.php file, it has a separate file which is "class-wp-metadata-lazyloader.php"

Do I still add the code above to my functions.php file or to "class-wp-metadata-lazyloader.php" file"?

Thanks in advance!
The code is not in functions.php if not added. That code is from wordpress to deactivate the default lazy load, so it should be added
 

daniel-97

Well-Known Member
The code is not in functions.php if not added.
I didn't add any code for Lazy Load in any of my Wordpress core files, I Googled and seems like since the 5.4 update, Wordpress included lazy loading to it's core file. I checked and found that file, which I mentioned above: class-wp-metadata-lazyloader.php
That code is from wordpress to deactivate the default lazy load, so it should be added
Now, should I add the code to my functions.php file or to the class-wp-metadata-lazyloader.php file?
1598413087962.png
1598413102726.png
 

Mar

Moderator
I didn't add any code for Lazy Load in any of my Wordpress core files
The lazy load is a default feature of wordpress, it is not added by a user.
Now, should I add the code to my functions.php file or to the class-wp-metadata-lazyloader.php file?
The code is supposed to be added to functions.php. But user added it to functions.php and broke the site. I suggested to install Code Snippet plugin and add the codes there, it worked. It will depend on the site. it may work at your end if you add the code directly in function.php, just try. The class-wp-metadata-lazyloader.php is a core file of wordpress for the lazy load, you cannot disable it by adding the code and don't mess with it.
 

daniel-97

Well-Known Member
The code is supposed to be added to functions.php. But user added it to functions.php and broke the site. I suggested to install Code Snippet plugin and add the codes there, it worked. It will depend on the site. it may work at your end if you add the code directly in function.php, just try.
Will try both, thanks!
The class-wp-metadata-lazyloader.php is a core file of wordpress for the lazy load, you cannot disable it by adding the code and don't mess with it.
Lucky for me, I planned to delete it :) Learn something new everyday!
 
Top