Add zoomable image wrapper with hover magnifier effect

This commit is contained in:
interlope committed 2026-05-30 02:52:46 +02:00
1 parent 8d44725090
commit 499aaeed6c
2 files changed
+33 -2

No files matched your search

+28 -2
View File
@@ -1222,11 +1222,37 @@ footer.footer-modern a:hover {
transform: scale(1);
}
/* Hint that content images are clickable */
.content img {
/* Zoomable image wrapper — JS wraps each content image in this span */
.zoomable-wrap {
position: relative;
display: inline-block;
cursor: zoom-in;
}
/* Magnifier badge that appears on hover */
.zoomable-wrap::after {
content: '';
position: absolute;
bottom: 8px;
right: 8px;
width: 30px;
height: 30px;
border-radius: 50%;
background:
rgba(0, 0, 0, 0.55)
url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM6.5 11a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9zM7 4.5a.5.5 0 0 0-1 0V6H4.5a.5.5 0 0 0 0 1H6v1.5a.5.5 0 0 0 1 0V7h1.5a.5.5 0 0 0 0-1H7V4.5z'/%3E%3C/svg%3E")
center / 14px no-repeat;
opacity: 0;
transform: scale(0.8);
transition: opacity 0.18s ease, transform 0.18s ease;
pointer-events: none;
}
.zoomable-wrap:hover::after {
opacity: 1;
transform: scale(1);
}
/* ========================================
TABLE OF CONTENTS (left sidebar, article view)
======================================== */
+5
View File
@@ -369,6 +369,11 @@
}
Array.prototype.forEach.call(images, function (el) {
// Wrap in a span so CSS can attach the hover badge via ::after
var wrap = document.createElement('span');
wrap.className = 'zoomable-wrap';
el.parentNode.insertBefore(wrap, el);
wrap.appendChild(el);
el.addEventListener('click', function () { open(el.src, el.alt); });
});