Ensure ipp.lightbox.options is an object
This commit is contained in:
+2
-2
@@ -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
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user