I have a folder with thumbnails. These can be .jpg or .gif or .png etc. How can I select a file with only the name using javascript?
For example if there is a file called tree.jpg I want to find it with only using tree. The folder in which these thumbnails are located is always the same. Below is the code snippet I'm using. My question is about the line with var src. In that line I want to find the file in the folder thumbnails with only using the name.
(projects is a json file)
function buildWork(projects) {
var container = document.getElementById('projects');
var row = document.createElement('div');
row.className = 'row no-gutters';
container.appendChild(row);
for(var i in projects) {
col = document.createElement('div');
col.className = 'col-6 col-md-4 item thumbnail';
var src = "thumbnails/" + project.name;
col.innerHTML = '<img src='+ src +'></img>';
row.appendChild(col);
}
}