Thanks @Teodor, I should have asked first before trying all this, haha.
Out of interest, and incase someone else think they are a smartass like me, and wastes time trying to trick it into submission, here is what I have tried so far.
Manually adding a class to the actual slides.
<dmx-slide class="lazyload" id="slide1" url="images/image1.jpg"></dmx-slide>
<dmx-slide class="lazyload" id="slide1" url="images/image1.jpg"></dmx-slide>
Does not work because the img tag this generates does not get the class
Manually adding a class the parent slideshow itself.
<dmx-slideshow id="slideshow1" show-nav="true" pause-on-hover="true" class="lazyload">
<dmx-slide id="slide1" url="images/image1.jpg"></dmx-slide>
<dmx-slide id="slide1" url="images/image1.jpg"></dmx-slide>
Does not work although the class is not dropped but it is not on the img tag
Then I got super duper smart and just left the default slideshow code as it was like this
<dmx-slideshow id="slideshow1" show-nav="true" pause-on-hover="true">
<dmx-slide id="slide1" url="images/image1.jpg"></dmx-slide>
<dmx-slide id="slide1" url="images/image1.jpg"></dmx-slide>
</dmx-slideshow>
And decided I need to add the class to the img tag, and I need to change src
to data-src
and add the data-sizes="auto"
parameter. So I modified the dmxAppConnect/dmxSlideshow.js
file from this
var o=document.createElement("img");o.setAttribute("src",e.url)
to this
var o=document.createElement("img");o.setAttribute("class","lazyload"),o.setAttribute("data-sizes","auto"),o.setAttribute("data-src",e.url)
Although this change actually did everything correctly to the img tag it unfortunately still did not work. But not to worry, I was not out of ideas yet.
Maybe I just needed to add a placeholder image to the src
tag so it loaded that instead and would swap it out for me on scroll, so i tried this next.
var o=document.createElement("img");o.setAttribute("class","lazyload"),o.setAttribute("src","data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="),o.setAttribute("data-sizes","auto"),o.setAttribute("data-src",e.url)
Again it did add what I wanted to the img tag, but still did not work properly for lazy load
Moral of the story It took me an hour of trying for nothing, and @Teodor came up with a solution that works in about 5 minutes.
Thanks Teodor, much appreciated, I will try and stop playing with internal Wappler files in future. 