Cropped thumbnails
Crop thumbnails with CSS, not on the server.
The thumbnail keeps the whole photo and object-fit: cover cuts the square, so the box can open with a zoom out of the crop to the whole photo, and close back into it.
live · Cropped thumbnails
<ul id="frames" class="squares" role="list">
<li><a href="/media/photo-7-1600.jpg" data-dlb-width="1600" data-dlb-height="1066"><img src="/media/photo-7-480.jpg" alt="Soft bands of violet, yellow, mint and purple" /></a></li>
<li><a href="/media/photo-4-1600.jpg" data-dlb-width="1066" data-dlb-height="1600"><img src="/media/photo-4-480.jpg" alt="Amber stripes across dark red" /></a></li>
<li><a href="/media/photo-6-3200.jpg" data-dlb-width="3200" data-dlb-height="800"><img src="/media/photo-6-720.jpg" alt="Purple, a band of orange, and pale lilac" /></a></li>
<li><a href="/media/photo-5-1600.jpg" data-dlb-width="1066" data-dlb-height="1600"><img src="/media/photo-5-480.jpg" alt="A pale green band between mint and dark green" /></a></li>
</ul>.squares {
display: grid;
grid-template-columns: repeat(auto-fill, 7rem);
gap: 0.5rem;
margin: 0;
padding: 0;
list-style: none;
}
/* The thumbnail holds the whole photo; CSS cuts the square */
.squares img {
display: block;
width: 100%;
aspect-ratio: 1;
object-fit: cover;
}import { lightbox } from "dialog-lightbox";
lightbox({ gallery: document.querySelector("#frames"), dialog: document.querySelector("dialog.box") });


