#224 Fix missing caption
This commit is contained in:
@@ -125,3 +125,26 @@ html.pswp-no-arrows .pswp__button--arrow {
|
|||||||
.pswp__bg {
|
.pswp__bg {
|
||||||
transition: opacity var(--pswp-transition-duration);
|
transition: opacity var(--pswp-transition-duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Image caption (from EXIF description) - centered in the 56px bottom margin
|
||||||
|
carved out by the lightbox `padding.bottom` setting. */
|
||||||
|
.pswp__caption {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
height: 56px;
|
||||||
|
padding: 0 24px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.4;
|
||||||
|
text-align: center;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pswp__caption[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|||||||
+27
-1
@@ -303,7 +303,10 @@ function createTile (index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const img = document.createElement('img')
|
const img = document.createElement('img')
|
||||||
img.alt = item.description || ''
|
// alt left empty: browsers paint alt text over the thumbhash background
|
||||||
|
// while the thumbnail downloads. Description (if any) is shown in the
|
||||||
|
// lightbox caption instead.
|
||||||
|
img.alt = ''
|
||||||
img.dataset.src = item.thumbnailUrl
|
img.dataset.src = item.thumbnailUrl
|
||||||
img.onerror = onThumbError
|
img.onerror = onThumbError
|
||||||
a.appendChild(img)
|
a.appendChild(img)
|
||||||
@@ -683,6 +686,29 @@ function initLightbox () {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Caption from EXIF description (only present when item.description is set;
|
||||||
|
// server-side gated on ipp.showMetadata.description). Content is already
|
||||||
|
// HTML-escaped in render.ts, so innerHTML assignment is safe.
|
||||||
|
lightbox.on('uiRegister', () => {
|
||||||
|
lightbox.pswp.ui.registerElement({
|
||||||
|
name: 'caption',
|
||||||
|
order: 9,
|
||||||
|
isButton: false,
|
||||||
|
appendTo: 'root',
|
||||||
|
onInit: (el, pswp) => {
|
||||||
|
el.classList.add('pswp__caption')
|
||||||
|
const render = () => {
|
||||||
|
const item = items[pswp.currIndex]
|
||||||
|
const text = (item && item.description) || ''
|
||||||
|
el.innerHTML = text
|
||||||
|
el.hidden = !text
|
||||||
|
}
|
||||||
|
render()
|
||||||
|
pswp.on('change', render)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Hash navigation: sync window.location.hash with the open slide
|
// Hash navigation: sync window.location.hash with the open slide
|
||||||
lightbox.on('uiRegister', () => {
|
lightbox.on('uiRegister', () => {
|
||||||
const pswp = lightbox.pswp
|
const pswp = lightbox.pswp
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ try {
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backward-compat shim: users with a legacy `lightGallery.*` config section
|
// Backward-compatability shim for 1.x users with a legacy `lightGallery.*` config section
|
||||||
// get the few keys most of them had set mapped onto the current
|
|
||||||
// `ipp.lightbox.*` schema, with a single startup notice.
|
|
||||||
if (config.lightGallery && typeof config.lightGallery === 'object') {
|
if (config.lightGallery && typeof config.lightGallery === 'object') {
|
||||||
const lg = config.lightGallery as Record<string, unknown>
|
const lg = config.lightGallery as Record<string, unknown>
|
||||||
const mobile = (lg.mobileSettings || {}) as Record<string, unknown>
|
const mobile = (lg.mobileSettings || {}) as Record<string, unknown>
|
||||||
|
|||||||
Reference in New Issue
Block a user