• Resolved Norm Sash

    (@normsash)


    Hi,

    I am utilizing lazyload on the site. There are a number of elements on the site that have the data-no-lazy attrib, which Litespeed honors and does not lazyload those images.

    However, I would like to override that behavior (at least for testing purposes.) Is there a way that I can override the “data-no-lazy” behavior of Litespeed and still load the images lazyload?

    There is the litespeed_media_lazy_img_excludes API method but I couldn’t find documentation on that and don’t know if it can actually override the default data-no-lazy behavior.

    Thanks,
    -Norm

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support qtwrk

    (@qtwrk)

    Hi,

    sadly no , and that filter is to exclude images , not to include

    only way to get it is to modify the source code in /src/media.cls.php , around line 576-ish , you will see the attribute check condition

    Best regards,

    Thread Starter Norm Sash

    (@normsash)

    Thanks for the response. I thought that might be the answer. Thanks for letting me know where in the source I can look… I will only modify it for testing purposes though so I can try out a couple of things.

    Maybe this could be added as a filter or option at some point.

    Thanks,
    -Norm

    Plugin Support qtwrk

    (@qtwrk)

    usually these attributes were added for certain reason , and it’s better safe than sorry , to obey it instead of forcefully bypass/ignore it

    Thread Starter Norm Sash

    (@normsash)

    Yeah, I’m using a page builder and the module vendor put in the no-lazy-load attrib because there was another caching service (not Litespeed) that was having difficulty rendering galleries. So the vendor added it to all of the various grid modules.

    I’ve done some testing with Litespeed, and with the combination of LQIP and lazyload I’m not seeing the same issues that were reported with the other caching service.

    So I can either go back to the page builder vendor and ask them to modify all of their various modules to add in a WP filter, and then put in my code the filters for all the various modules… or I can just globally disable the no-lazy-load and then add a CSS class or selector to force lazyload exclude anywhere I notice a problem.

    … at least that was my plan

    • This reply was modified 3 years, 4 months ago by Norm Sash.
    Plugin Support qtwrk

    (@qtwrk)

    you can use this filter

    function remove_data_no_lazy( $content ) {
       $content=str_replace( 'data-no-lazy', '', $content );
       return $content;
       
    }
    add_filter( 'litespeed_buffer_before', 'remove_data_no_lazy', 0);

    to modify it before LSCWP processes , didn’t test though , but the idea should work

    Thread Starter Norm Sash

    (@normsash)

    Thanks qtwrk! I tested it out and that worked – removed the data-no-lazy from all the elements. I only made one small change to the code for the attrib. Here’s the code I used:

    function remove_data_no_lazy( $content ) {
       $content=str_replace( 'data-no-lazy="1"', '', $content );
       return $content;
       
    }
    add_filter( 'litespeed_buffer_before', 'remove_data_no_lazy', 0);

    Thanks again.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to include data-no-lazy in lazyload’ is closed to new replies.