• Resolved wp-boffin

    (@wp-boffin)


    I have tried the Lazy Load by WP Rocket plugin — and the improvement in page load times is impressive. However, there are four images on my home page that I would like to exclude from lazy loading.

    Your plugin FAQs, state that images can be excluded by “Simply add a data-no-lazy=”1″ property” to the img tag; and then using the filter rocket_lazyload_excluded_attributes

    Two support requests:
    (1) please explain how and where exactly the data-no-lazy=”1″ attribute is set in WordPress and
    (2) please provide the code snippet that I need to add to the functions.php file to filter out / exclude particular images.

    Thank you.

    • This topic was modified 5 years, 4 months ago by wp-boffin.
Viewing 1 replies (of 1 total)
  • Plugin Contributor WP Rocket

    (@wp_rocket)

    Hi,

    1) The data-no-lazy="1" attribute is not set in WordPress, you need to add it manually to your images. If you can’t do that, you will need to exclude them with the filters.

    2) Here is an example of how to use the filter, you will need to change the value based on your case:

    add_filter( 'rocket_lazyload_excluded_attributes', function( $excluded ) {
        $excluded[] = 'excluded-pattern';
    
        return $excluded;
    } );
Viewing 1 replies (of 1 total)
  • The topic ‘Exclude Images Using data-no-lazy=”1″’ is closed to new replies.