There is a simple method to achieve this task, especially if all the files are stored in one folder - just loop through the folder. Should you wish to display them in separate divs, some modifications may be required on the code snippet provided below.
In the example, I have used the number 75 for demonstration purposes; in your case, adjust it to 500. If your files consist of both jpg and png formats as mentioned, you can organize them into subfolders (jpg and png) and assign different values accordingly (e.g., set jpg to 300 and png to 200).
The code snippets showcased here provide a foundation for image display based on file format. Feel free to tweak them further to suit your specific requirements.
var jpgcontainer = document.getElementById('jpg');
var pngcontainer = document.getElementById('png');
var files = {
'jpg': 300
};
var files2 = {
'png': 200
};
for (var jpgext in files) {
for (var i = 0; i < files[jpgext]; i++) {
var jpgsrc = "images/jpg/" + (i + 1) + "." + jpgext;
var jpgimg = new Image();
jpgimg.src = jpgsrc;
jpgcontainer.appendChild(jpgimg);
}
}
for (var pngext in files2) {
for (var j = 0; j < files2[pngext]; j++) {
var pngsrc = "images/png/" + (j + 1) + "." + pngext;
var pngimg = new Image();
pngimg.src = pngsrc;
pngcontainer.appendChild(pngimg);
}
}
img {
width: 50px;
height: 50px;
display: block;
}
<div id="imgcontainer">
<section id="jpg">
</section>
<section id="png">
</section>
</div>
https://i.stack.imgur.com/4OI0t.png