Great video, very useful. Did you work out how to ...
# news
c
Great video, very useful. Did you work out how to work with Slimsy to do background images? I noted your new codeshare site appears to have done it. Or at least there's a query string at the end of the background image url.
c
Thanks Craig. I’ve not gotten around to implementing slimsy yet on codeshare. I plan on doing it soon.
I did have it on my old codeshare site. You would add a class of lazyload to the div and you would add a data attribute of
data-bg="yourhighqualityurlhere"
and then you would put your low quality image url in the
style="background:url('lowqualityurlhere')"
so it would first load your low quality image and then it would replace it with the high quality one
And you reference the lazysizes js file in your page
Here is the HTML for the header on my old version of my site
Copy code
html
    <div class="page-header-image lazyload" data-bg="/media/z3ta4wcc/codeshare-header.jpg?anchor=center&mode=crop&width=1904&height=604&rnd=132678230988700000" style="background-image: url('/media/z3ta4wcc/codeshare-header.jpg?anchor=center&mode=crop&width=190&height=60&rnd=132678230988700000');">
    </div>
c
Interesting, thanks. I can see how that would give you a better page load speed index but not offer up the right image for the screen size.
c
Yeah the background one doesn't adjust the image to the screen size but the slimsy foreground ones do
c
Yeah, have used Slimsy for years in everything. The new tag helper is very nice. The docs could do with some TLC though. I think it actually does more than it's letting on 😉