Support » Plugin: Lazy Load - Optimize Images » Excluding images by class doesnt work for me

  • drachires

    (@drachires)


    Hello,

    can you please tell me how to fix my code here … it lazyloads the images although I think I choosed good parameters, maybe code is wrong because there were some differences between your documentation and plugin file:

    namespace WP_Rocket\Helpers\lazyload\exclude_sources;

    // Standard plugin security, keep this line in place.
    defined( ‘ABSPATH’ ) or die();

    function exclude_src( array $excluded_src ) {

    // EDIT/REPLACE THESE EXAMPLES:
    //
    $excluded_src[] = ‘150×150’;
    $excluded_src[] = ‘InstaHero_logo’;

    // STOP EDITING.

    return $excluded_src;
    }
    add_filter( ‘rocket_lazyload_excluded_src’, __NAMESPACE__ . ‘\exclude_src’ );

    function rocket_lazyload_exclude_class( array $attributes ) {
    $attributes[] = ‘class=”flex-active”‘;
    $attributes[] = ‘class=”wp-post-image”‘;

    return $attributes;
    }
    add_filter( ‘rocket_lazyload_excluded_attributes’, ‘rocket_lazyload_exclude_class’ );

    … I want to exclude Logo, product main images and thumbnails, basically all above the fold for product images …

    The page I need help with: [log in to see the link]

  • The topic ‘Excluding images by class doesnt work for me’ is closed to new replies.