I am trying to implenent lazy image load functionality for image tag. Is there any way to implement lazy image load functionality in SXA while loading images on page?
Yes, you can do it! I will skip part of how the lazy loading should work as this is plenty of blog posts about it like:
But here is one thing SXA SXA can help with. Rendering Variants supports tokens inside of the data attributes. Let's imagine that you have few pages and each of those pages has an Image field of type
Image. You want to display them using Page List and have all those images lazy loaded. In such case your rendering variant can look like this:
$(Image) token will check if Image is an
ImageField and contains media and if yes it will render a link to that media item like this: