I'm doing this in Wordpress using Sage theme. I want to display different images from a collection I provide to be displayed only once without repeating. I tried to do a simple JS one but it didn't work, it works when I try it as images not gif format. Below is my code, also one more thing right now I am hosting images somewhere and it would be really nice if I can use assets/images instead
var images = [
'https://gifyu.com/image/IwmR',
'https://gifyu.com/image/Iwmj',
'https://gifyu.com/image/Iwm0',
'https://gifyu.com/image/Iwm6',
'https://gifyu.com/image/Iwmi',
'https://gifyu.com/image/IwmC',
]
function randImg() {
var size = images.length
var x = Math.floor(size * Math.random())
document.getElementById('animateImage').src = images[x];
}
randImg()
HTMl part
<div class="container">
<div class="row">
<div class="col-6">
<div class="card my-5 mx-5" style="width: 25rem;">
<img class="card-img-top" src= "" id="animateImage" alt=""></img>
<div class="card-body">
<h5 class="card-title text-center" id="title"></h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</div>
</div>
</div>