I have a gallery on my portfolio website which shows all of my pictures in a masonry type grid. Now I would like to randomize those pictures without showing them more then once ! so I don't have the same images in the gallery.
// place your images in this array
var random_images_array = [
'Laundry_Shoot (1).JPG',
'Laundry_Shoot (5).JPG',
'Laundry_Shoot (10).JPG',
'Laundry_Shoot (28).JPG'
];
function getRandomImage(imgAr, path) {
path = path || 'images/portfolio/'; // default path here
var num = Math.floor(Math.random() * imgAr.length);
var img = imgAr[num];
var imgStr = '<img src="' + path + img + '" alt = "">';
document.write(imgStr);
document.close();
}
<!-- END FILTER BUTTONS -->
<div class="gallery">
<div class="img filterDiv film portret">
<script type="text/javascript">
getRandomImage(random_images_array, 'images/portfolio/')
</script>
</div>
<div class="img filterDiv film portret">
<script type="text/javascript">
getRandomImage(random_images_array, 'images/portfolio/')
</script>
</div>
<div class="img filterDiv film portret">
<script type="text/javascript">
getRandomImage(random_images_array, 'images/portfolio/')
</script>
</div>
</div>
</div>