diff --git a/web/static/image/placeholder.png b/web/static/image/placeholder.png new file mode 100644 index 0000000..bf1d310 Binary files /dev/null and b/web/static/image/placeholder.png differ diff --git a/web/static/scripts/gallery.js b/web/static/scripts/gallery.js index 146f7f0..7fe1281 100644 --- a/web/static/scripts/gallery.js +++ b/web/static/scripts/gallery.js @@ -39,11 +39,6 @@ $(document).ready(function() { }); }); -const myModal = new bootstrap.Modal('#Wallpaper', { - keyboard: false -}); -myModal.show(); - function wallpaper(data) { $(".preloader").hide(); data = data.reverse(); @@ -51,32 +46,52 @@ function wallpaper(data) { for (let i = 0; i < data.length; i++, id++) { ids.push(data[i]); - if (ids.filter((item) => item.url === data[i].url).length > 1) { + if (ids.filter((item) => item['url'] === data[i]['url']).length > 1) { continue; } + let image = new Image(); + image.src = ids[id]['media_type'] === "video" ? + `https://img.youtube.com/vi/${ids[id]['url'].slice(30, 41)}/maxresdefault.jpg` : + ids[id]['url']; + + image.onload = function() { + if(image.width+image.height !== 210) { + $(`img[data-src="${image.src}"]`).attr("src", `${image.src}`); + } + } + if (ids[id]['media_type'] === "image") { $(".header-row").append(`
`); } else { $(".header-row").append(` -Author: ${ids[id]['copyright']}
@@ -94,27 +110,32 @@ function wallpaper(data) {Explanation: ${ids[id]['explanation']}
`; - title.innerHTML = `Author: ${ids[id]['copyright']}
Date of publication: ${ids[id]['date']}
Explanation: ${ids[id]['explanation']}
`; - title.innerHTML = `