Hey @scrlk
Our Lazy Load Optimization doesn’t work with manually added images.
If you want to use this feature, you should use the default WordPress image display functions like:
wp_get_attachment_image_url
get_post_thumbnail_url
etc
Because we use the hooks in the functions mentioned above to lazyload the images.
And without these hooks, this optimization cannot work.
Regards,
Stanimir
Thread Starter
scrlk
(@scrlk)
Okay, at least I’m using the correct function. I am using wp_get_attachment_image_url() to pull the image. But it’s still not working…
Here is how my code is setup. I prepare all the data ahead of time in a loop because I output the same image in a couple of places.
loop1
(do some stuff)
$data[$count]['image'] = get_post_thumbnail_url()
(do some more stuff)
endloop1
loop2
(do some stuff)
echo '<img src="'.$data[$count]['image'].'" alt="'.$data[$count]['name'].'"></a>';
(do some more stuff)
endloop2
loop3
(do some stuff)
echo '<img src="'.$data[$count]['image'].'" alt="'.$data[$count]['name'].'"></a>';
(do some more stuff)
endloop3
Is this why the lazy loading doesn’t work? What would be the proper approach in PHP to get it working?
-
This reply was modified 5 years, 6 months ago by
scrlk.
-
This reply was modified 5 years, 6 months ago by
scrlk.