WordPress.org

Ready to get started?Download WordPress

Forums

[lazy load] images loaded via ajax not loading at all (2 posts)

  1. bheadrick
    Member
    Posted 2 years ago #

    I tried rerunning the script in the plugin after the ajax load runs but it doesn't help. is there any way to selectively disable lazy loading?

  2. bheadrick
    Member
    Posted 2 years ago #

    ok, I figured out one way to get around this, though it's not my favorite solution. The image loaded in my ajax has a specific class.

    I simply added this:
    if(!strpos($content,'image-class-name'))
    before this:
    $content = preg_replace( '#<img([^>]+?)src=[\'"]([^\'">]*)[\'"]([^>]*)>#', sprintf( '<img${1}src="%s" data-lazy-src="${2}"${3}><noscript><img${1}src="${2}"${3}></noscript>', $placeholder_image ), $content );

    I wish this image could be lazy loaded as well, but it's not a big deal since it doesn't impact the page load time.

Topic Closed

This topic has been closed to new replies.

About this Topic