Add this snippet to functions.php:Anybody know how to disable the inbuild lazy load of wordpress 5.5 ...?
You're welcome. Flatsome has its own default lazy load. I am observing which work better.Thanks mar
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"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
);
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 addedIn 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!
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.phpThe code is not in functions.php if not added.
Now, should I add the code to my functions.php file or to the class-wp-metadata-lazyloader.php file?That code is from wordpress to deactivate the default lazy load, so it should be added
The lazy load is a default feature of wordpress, it is not added by a user.I didn't add any code for Lazy Load in any of my Wordpress core files
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.Now, should I add the code to my functions.php file or to the class-wp-metadata-lazyloader.php file?
Will try both, thanks!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.
Lucky for me, I planned to delete it Learn something new everyday!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.