Jump to content

Randomizing images in a display gallery

Recommended Posts

  • 4 weeks later...
  • Replies 1
  • Views 216
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted

@ColinMaloneArt You can use this code to Website Tools > Code Injection > Footer

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
    var $slideshow = $('body.homepage .gallery-fullscreen-slideshow-list');
    var $slides = $slideshow.children(); 
    $slides.css({
        visibility: 'hidden',
        display: 'none'
    });
    var randomSlide = $slides.eq(Math.floor(Math.random() * $slides.length));
    
    randomSlide.css({
        visibility: 'visible',
        display: 'block' 
    });
});

</script>

image.thumb.png.fac83834f0fdee388b7e9a250254b619.png

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

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.