Jump to content

Different Images on Refresh

Recommended Posts


password: madcap

Hi! My client would like the large, main gallery on her home page (which is currently set to automatically transition between slides), to only show 1 image at a time, and then show a new image on reload or revisit. I've seen past posts in the forum about this, but I'm confused. Down below is the code I've seen, but what do I need to replace in the code? Just the image URLs? And I think it needs to go into code injection > footer? 

document.addEventListener('DOMContentLoaded', function() {
  var images = [
].sort( () => .5 - Math.random() );
    var randImage = images[0];
    document.querySelector(".homepage article.sections section:first-child .section-background img").src = randImage;
    document.querySelector(".homepage article.sections section:first-child .section-background img").setAttribute("srcset", "");



Link to comment
  • Replies 1
  • Views 411
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.