128 lines
3.6 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Archive</title>
<style>
.gallery {
display: grid;
2025-04-01 16:56:10 +01:00
grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
gap: 10px;
}
.gallery img {
width: 100%;
height: auto;
border-radius: 5px;
cursor: pointer;
}
/* Lightbox styles */
.lightbox {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
justify-content: center;
align-items: center;
2025-04-01 16:51:43 +01:00
flex-direction: column;
}
.lightbox img {
max-width: 90%;
max-height: 90%;
border-radius: 5px;
}
.lightbox .close {
position: absolute;
top: 20px;
right: 30px;
font-size: 30px;
color: white;
cursor: pointer;
}
2025-04-01 16:51:43 +01:00
.arrow {
position: absolute;
top: 50%;
font-size: 40px;
color: white;
cursor: pointer;
user-select: none;
transform: translateY(-50%);
}
.arrow.left {
left: 20px;
}
.arrow.right {
right: 20px;
}
#lightbox-prompt {
color: #ccc;
font-family: monospace;
white-space: pre-wrap;
background: rgba(0, 0, 0, 0.6);
padding: 10px 20px;
border-radius: 10px;
max-width: 80%;
text-align: left;
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Image Archive</h1>
<div class="gallery">
{% for image in images %}
<img src="{{ url_for('images', filename=image.filename) }}" alt="Image" loading="lazy" onclick="openLightbox({{ loop.index0 }})">
{% endfor %}
</div>
<!-- Lightbox -->
<div class="lightbox" id="lightbox">
<span class="close" onclick="closeLightbox()">&times;</span>
2025-04-01 16:51:43 +01:00
<span class="arrow left" onclick="prevImage()">&#10094;</span>
<img id="lightbox-img" src="">
<p id="lightbox-prompt"></p> <!-- 👈 Add this line -->
2025-04-01 16:51:43 +01:00
<span class="arrow right" onclick="nextImage()">&#10095;</span>
</div>
<script>
2025-04-01 16:51:43 +01:00
let images = [
{% for image in images %}
{
src: "{{ url_for('images', filename=image.filename) }}",
prompt: `{{ image.prompt | escape }}`
},
2025-04-01 16:51:43 +01:00
{% endfor %}
];
let currentIndex = 0;
function openLightbox(index) {
currentIndex = index;
document.getElementById("lightbox-img").src = images[currentIndex].src;
document.getElementById("lightbox-prompt").textContent = images[currentIndex].prompt;
document.getElementById("lightbox").style.display = "flex";
}
function closeLightbox() {
document.getElementById("lightbox").style.display = "none";
}
2025-04-01 16:51:43 +01:00
function nextImage() {
currentIndex = (currentIndex + 1) % images.length;
openLightbox(currentIndex);
2025-04-01 16:51:43 +01:00
}
2025-04-01 16:51:43 +01:00
function prevImage() {
currentIndex = (currentIndex - 1 + images.length) % images.length;
openLightbox(currentIndex);
2025-04-01 16:51:43 +01:00
}
</script>
</body>
</html>