You could use the querySelectorAll
and use a regular expression to get the images with the extensions:
var images = document.querySelectorAll('img[src$=".jpg"], img[src$=".png"], img[src$=".gif"]');
var srcList = [];
for(var i = 0; i < images.length; i++) {
srcList.push(images[i].src);
}
To generate a list of images you could do:
for(var i = 0; i < images.length; i++) {
var img = document.createElement('img');
img.src = images[i].src;
document.body.appendChild(img);
}
You have to add some CSS to make it a grid.