Ensure ipp.lightbox.options is an object

This commit is contained in:
Alan Grainger
2026-05-30 10:55:50 +08:00
parent 7cdc7c21f6
commit c07ef0fab3
2 changed files with 9 additions and 3 deletions
+2 -2
View File
@@ -37,7 +37,7 @@ import { thumbHashToDataURL } from '/share/static/thumbhash/thumbhash.js'
* @property {boolean} [showArrows] * @property {boolean} [showArrows]
* @property {boolean} [showDownload] * @property {boolean} [showDownload]
* @property {boolean} [mobileArrows] * @property {boolean} [mobileArrows]
* @property {Record<string, any>} [options] * @property {Record<string, unknown>} [options]
*/ */
/** /**
@@ -668,7 +668,7 @@ function buildDataSource () {
} }
function initLightbox () { function initLightbox () {
const { options = {} } = lightboxConfig; const { options = {} } = lightboxConfig
lightbox = new PhotoSwipeLightbox({ lightbox = new PhotoSwipeLightbox({
bgOpacity: 1, bgOpacity: 1,
+7 -1
View File
@@ -284,6 +284,12 @@ class Render {
// item if the cover asset has been filtered out (e.g. trashed). // item if the cover asset has been filtered out (e.g. trashed).
const coverId = share.album?.albumThumbnailAssetId const coverId = share.album?.albumThumbnailAssetId
const ogImageItem = (coverId && items.find(i => i.id === coverId)) || items[0] const ogImageItem = (coverId && items.find(i => i.id === coverId)) || items[0]
// Guard against an operator setting ipp.lightbox.options to a non-object;
// a string would otherwise spread character-by-character into PhotoSwipe.
const rawLightboxOptions = getConfigOption('ipp.lightbox.options', {})
const lightboxOptions: Record<string, unknown> = (rawLightboxOptions && typeof rawLightboxOptions === 'object' && !Array.isArray(rawLightboxOptions))
? rawLightboxOptions as Record<string, unknown>
: {}
const props: GalleryProps = { const props: GalleryProps = {
items, items,
title: this.title(share), title: this.title(share),
@@ -299,7 +305,7 @@ class Render {
showDownload: downloadAllowed && !!getConfigOption('ipp.lightbox.showDownload', true), showDownload: downloadAllowed && !!getConfigOption('ipp.lightbox.showDownload', true),
showArrows: !!getConfigOption('ipp.lightbox.showArrows', true), showArrows: !!getConfigOption('ipp.lightbox.showArrows', true),
mobileArrows: !!getConfigOption('ipp.lightbox.mobileArrows', false), mobileArrows: !!getConfigOption('ipp.lightbox.mobileArrows', false),
options: getConfigOption('ipp.lightbox.options', {}) as Record<string, unknown> options: lightboxOptions
}, },
groupByDate groupByDate
} }