• Resolved wprox

    (@wprox)


    Hi Florian,

    Thank you for all your great work here!

    I want to prevent an image inside of a picture element from lazyloading.

    I tried 2 approaches, and the image is still lazyloading:

    1. added do_not_lazyload as a class inside the img tag AND in Settings > Media css classes to avoid lazyloading entry box.
    2. added instead data-no-lazyload attribute not set to anything or set to “1” inside img tag.

    Help?

    Thanks ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Hey @wprox,

    I think it should work if you add the class or the attribute to the picture element instead of the img. Hope that helps! ??

    Best,
    Florian

    Thread Starter wprox

    (@wprox)

    Thanks so much for the quick response Florian!

    That worked.

    Interesting, it seemed like everything in the picture element is controlled in the img section, so hadn’t added any attributes to the picture tag before…

    Thank you ??

    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Great to hear that! ??

    The important part is that line: https://github.com/florianbrinkmann/lazy-loading-responsive-images/blob/master/src/Plugin.php#L203

    It checks if that is an img element that is *not* part of a picture element. The img elements in picture elements are processed with the same method like the normal images, but the call for that happens in the modify_picture_markup (there I fetch the child elements from picture – namely source and img – and loop them to modify the markup) ??

    Best,
    Florian

    Thread Starter wprox

    (@wprox)

    Interesting, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can’t prevent lazyload of image’ is closed to new replies.