Lazy load with custom img tags?
-
Hello, i’m on a twenty sixteen child theme. I have enabled “Site Accelerator” and it works just fine for all images. But lazy load doesn’t. And by that i mean no 1px placeholder as src. Images src is still the real image.
I believe this happens because i display images like this:
<img src="<?php echo get_the_post_thumbnail_url(); ?>" class="entry-thumb wp-post-image" alt="<?php echo $name; ?>" />
I understand Lazy load can’t work with this manual construction of the img tag. That’s fine. But could you tell me how can i modify my img tag so it’s Lazy loaded?
What classes or extra markup is needed? I assume i need to move the image url to data-lazy-src but what about the placeholder? Any extra classes or attributes needed?<img src="https://jetpack.com/placeholder.jpg" data-lazy-src="<?php echo get_the_post_thumbnail_url(); ?>" />
Note:https://jetpack.com/placeholder.jpg
doesn’t exist, what should the real placeholder be? Shall i create my own 1×1 px image and link to it?Please advise! Any tip is greatly appreciated.
- The topic ‘Lazy load with custom img tags?’ is closed to new replies.