Source file: modules/lazy-images/lazy-images.php
View in GitHubParameters
- An
-
(array) An array of strings where each string is a class.
Changelog
Since: Jetpack 5.9.0
apply_filters ( 'jetpack_lazy_images_blacklisted_classes', array An )
Source file: modules/lazy-images/lazy-images.php
View in GitHub(array) An array of strings where each string is a class.
Since: Jetpack 5.9.0
Here’s a quick example to exclude your logo (given the logo’s class “custom-logo”) from lazy loading:
How about if I want to exclude all woocomerce pictures??? But still lazy load anywhere else on my site?
Hi there!
I don’t think WooCommerce adds a single class to all images it touches, but an alternative might be to use this filter:
https://developer.jetpack.com/hooks/lazyload_is_enabled/
… to dynamically disable lazy loading on any page where the body tag has the class “woocommerce”.
This code is 100% untested, but it will get you started:
https://pastebin.com/raw/CRzNEPpR
Thanks!
Thanks to that code snippet. It was most helpful!. Can you share what is the syntax if I want to exclude more than one class? Thanks
Hi there,
One way to exclude multiple classes would be to adjust the above example like so:
Best!
Hi! This works but still it adds noscript tag which gives w3c error when I’m using picture tag http://prntscr.com/pb6oys. How will I fix it?
It’s currently not possible to remove those
noscript
tags. We’re tracking this issue here. I would recommend that you subscribe to the issue to follow our progress on this.I really need help creating a snippet for turning off Lazy Images only on the homepage.
You need to use this filter for this purpose https://developer.jetpack.com/hooks/lazyload_is_enabled/
To disable Lazy Images in the homepage only, you can try this code.