@sekiro The Bootstrap docs have a section on how to change the modal content based on what trigger is clicked: https://getbootstrap.com/docs/5.3/components/modal/#varying-modal-content
So you’d have a list of thumbnails:
<ul>
<li>
<a data-bs-toggle="modal" data-bs-target="#photo-modal" href="full-1.jpg">
<img src="thumb-1.jpg">
</a>
</li>
<li>
<a data-bs-toggle="modal" data-bs-target="#photo-modal" href="full-2.jpg">
<img src="thumb-2.jpg">
</a>
</li>
<li>
<a data-bs-toggle="modal" data-bs-target="#photo-modal" href="full-3.jpg">
<img src="thumb-3.jpg">
</a>
</li>
</ul>
Add a modal with that ID, and an image to hold the full-sized image:
<div class="modal fade" id="photo-modal" tabindex="-1" aria-labelledby="photo-modal-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="photo-modal-label">Photo</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<img src="">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Then some JavaScript that listens on the #photo-modal being triggered so that you can intercept the click, but change the image src to the href of the clicked thumbnail before showing:
var imageModal = document.querySelector('#image-modal');
if (imageModal) {
var imageModalImage = imageModal.querySelector('.modal-body img');
imageModal.addEventListener('show.bs.modal', function (event) {
imageModalImage.src = event.relatedTarget.href;
});
}
So you’ll now have full-sized images open in a modal if JavaScript is available, or it will gracefully fall back and just navigate to the full-sized image if JavaScript is not available in the user’s browser for whatever reason (they’ve disabled it, there’s an error in your JavaScript bundle, they’re on a ridiculously slow connection, etc).