apply_filters ( 'jetpack_lazy_images_blacklisted_classes', array An )

Allow plugins and themes to tell lazy images to skip an image with a given class.

Source file: modules/lazy-images/lazy-images.php

View in GitHub

Parameters

An

(array) An array of strings where each string is a class.


Changelog

Since: Jetpack 5.9.0


Notes

Have a note to contribute?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Comments

  1. Rodolfo says:

    Here’s a quick example to exclude your logo (given the logo’s class “custom-logo”) from lazy loading:

    
    add_filter( 'jetpack_lazy_images_blacklisted_classes', 'bbloomer_exclude_custom_logo_class_from_lazy_load', 999, 1 );
                   
    function bbloomer_exclude_custom_logo_class_from_lazy_load( $classes ) {
        $classes[] = 'custom-logo';
        return $classes;
    }   
    
    
    • How about if I want to exclude all woocomerce pictures??? But still lazy load anywhere else on my site?

    • Erez Speiser says:

      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

      • Jeremy says:

        Hi there,

        One way to exclude multiple classes would be to adjust the above example like so:

        function bbloomer_exclude_custom_logo_class_from_lazy_load( $classes ) {
          $classes[] = 'custom-logo';
          $classes[] = 'second-class';
          $classes[] = 'third-class';
          return $classes;
        }
        

        Best!

  2. Loayon Lou says:

    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?

  3. Sandra says:

    I really need help creating a snippet for turning off Lazy Images only on the homepage.