Home › Forums › General Issues › Lazy Loading Images
I’m trying to figure out how to lazy load images. Every WordPress plugin and external library I have tried so far has only loaded for example the first 4 images, and I have a page which contains for example 30 images placed at varying position down the page.
I have currently implemented jQuery.Lazy – http://jquery.eisbehr.de/lazy/ but I am totally willing to use a different library. This library loads only the first 5 images.
This is a stripped down version of what I have implemented on my main page:
<?php if (get_field('thumbnail_image')): ?> <div id="all-projects-featured-image"/> <a href="<?php echo get_permalink(); ?>"> <img class="lazy" data-src="<?php the_field('thumbnail_image'); ?>"/> </a> </div> <?php endif ?>
And this in the footer:
Cheers for any help!
If the URL is being added correctly to all of the
If the attributes are not being populated correctly, make sure that the field you’re using is returning a url and not something else.
Thanks for getting back in touch about this. It turns out I wasn’t using all the possible options in the script. I had set it with just the very basic options.
The updated script looks like this now and seems to be working well:
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.