// Fix for missing files
document.querySelector('#files').style.opacity = '1';

let images = document.querySelectorAll('#files img');
const regex  = /(\/photos\/[0-9a-zA-z-_.]+)/g;

[].forEach.call(images, function(img) {
    let imgSrc = img.getAttribute('src');
    if (imgSrc.includes('/photos/')) {
        let matches  = imgSrc.match(regex);
        imgSrc = matches[0];
    }
    img.addEventListener('click', () => {
        parent.selectImage(imgSrc);
    });
});