• Hi guys,

    many thanks for this thoughtful lazy-load plugin.

    I would like to disable lazy loading for the first image in every post as this is always visible. Perhaps even the first two images.

    Is there a way to do this for all posts without adding a css class to the first image in every post?

    Thank you very much for taking the time.

    • This topic was modified 4 years, 6 months ago by hamu.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Hi @hamu,

    hm, the only way that comes to my mind there is to hook a function to the_content that adds the skip-lazy class to the first one or two images it founds, before Lazy Loader processes the markup. The plugin has no option or something like that for this.

    Best,
    Florian

    Thread Starter hamu

    (@hamu)

    Hello Florian,
    thanks a lot for your reply.
    Unfortunately, I don’t know how hooking a function to “the_content” would work.
    I don’t have the skills to do that.
    If this is not a lot of work for you, can you show me what I need to add and where?

    If this would take a lot of your time, such an option could perhaps be considered for a future release?

    I can go through the posts manually and add the class.
    Definitely doable for me and it would still be worth it. I just think it makes for a better user experience.

    All the best.

    • This reply was modified 4 years, 6 months ago by hamu.
    • This reply was modified 4 years, 6 months ago by hamu.
    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Hi,

    hm, not sure about an extra option for that, I want to try to keep the number of options as small as possible.

    But I will take a look at it and post a code snippet later, that you can use to exclude the first image automatically. I will try to get this done on the weekend.

    Best,
    Florian

    Thread Starter hamu

    (@hamu)

    Thanks a lot Florian.
    Have a good day.

    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Hi @hamu,

    the code from this Gist should exclude the first image of the post content: https://gist.github.com/florianbrinkmann/abdf929694a72e75c33d7a4254301f42

    You can add it to the functions.php of your child theme (or parent theme, if you use a custom theme).

    Best,
    Florian

    Thread Starter hamu

    (@hamu)

    Wow, Florian. That is a lot of code you produced.

    Thank you very much.
    I’ll give it a go and report back.

    • This reply was modified 4 years, 6 months ago by hamu.

    this works for me, i`ve searched for a fix, and found it here 🙂

    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Hi @alios24,

    great to hear that! 🙂

    Best,
    Florian

    Oh my god, thanks a lot! I have been looking for ages for a plugin that has this function. As I use a large horizontal image in each post, it created a huge blank space taking the whole screen. Now the images loads immediately and others are lazy loaded, genial!

    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Hi @narubi,

    thanks for the feedback, great to hear that it works so good for you!

    Best,
    Florian

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Excluding the first post image’ is closed to new replies.