Hello!
I'm hoping to replicate this effect: https://bddw.com/ where the image element changes every time the page is reloaded. I've found some code samples for 7.0 and similarly older versions but having issues with implementation.
This is the code I am working with now:
<script>
(function(){
var images = [
"http://static1.squarespace.com/static/53453ebbe4b0d46770eb7505/5345482be4b01730378288f7/54b3a45de4b0d7856db8059e/1421059173445/",
"http://static1.squarespace.com/static/53453ebbe4b0d46770eb7505/5345482be4b01730378288f7/54c5f3c8e4b0d7a7fa84acc2/1422274046633/",
"http://static1.squarespace.com/static/53453ebbe4b0d46770eb7505/5345482be4b01730378288f7/54a78e9ae4b00f7c5fb39c4a/1421997719378/"
];
var imgCount = images.length;
var randNumber=Math.floor((Math.random() * imgCount) + 1);
imgURL = "url('" + images[randNumber-1] + "')";
var body=document.getElementById('collection-542ba4a1e4b032a0dde82b31');
body.style.backgroundImage=imgURL;
body.style.backgroundSize="100% auto";
body.style.backgroundRepeat="no-repeat";
}());
</script>
However, it doesn't seem to be doing anything.
I think part of the issue is the image sources are incorrect. How do I adequately find the image url from the asset library?
Thank you!!