Problem: Images become blurry when document width is shrunk because they are too large.
Im trying to lazyload a specific image when the window width is at a value that I have specified. The images are 2560px wide by default.
I am using the latest Revolution Slider and the latest WordPress version. Images are in .jpg format as they are the smallest. Images MUST be Lazy-loaded because there are 4 different sets of media queries.
The slider has 6 slides and each need an additional 3 or 4 images that will be swapped out depending on the size of the window.
I have read the Slider Revolution Docs but there is no example for my current situation and does not include enough of a technical explanation for me to get an idea of where to start.
My thinking:
Load the images using the built in Lazy load function with the ‘data-lazyload’ attribute, but how would i load multiple images in a single attribute?
Any help would be greatly appreciated.
You could use lazySizes with either this partial picture/srcset polyfill or in combination with either picturefill or respimage.
And then write the following markup:
You can also add effects in two ways either a JS animation using the
lazybeforeunveil
event in conjunction with the browsersload
event or using a CSS transition/CSS animation using the classeslazyload
,lazyloading
andlazyloaded
.Here are two examples:
1. Simple fadin after load
fadein while load with spinner (much preferred, if you want to support progressive jpgs or LQIP:
.lazyload {
opacity: 0;
}
.lazyloading {
opacity: 1;
transition: opacity 300ms;
background: #f7f7f7 url(loader.gif) no-repeat center;
}