PhotoSwipe lightbox options: customization

This commit is contained in:
John B
2026-05-26 22:53:35 +03:00
parent cf4d8f053d
commit 9a6740ab96
4 changed files with 11 additions and 4 deletions
+1
View File
@@ -220,6 +220,7 @@ The gallery's lightbox is powered by [PhotoSwipe](https://photoswipe.com/). Conf
| `showArrows` | `bool` | Show the prev/next arrows on desktop. They appear when the user hovers the lightbox. Default `true`. |
| `showDownload` | `bool` | Show a download button in the lightbox toolbar. Only takes effect when downloads are also allowed by `allowDownloadAll`. Default `true`. |
| `mobileArrows` | `bool` | Show prev/next arrows on mobile (under 640px viewport). Off by default since swipe is the natural mobile navigation. |
| `options` | `object` | Custom [PhotoSwipe options](https://photoswipe.com/options/) to override defaults (e.g. `{"wheelToZoom": true}`). |
Example: hide the download button inside the lightbox even though zip downloads are otherwise allowed:
+7 -3
View File
@@ -37,6 +37,7 @@ import { thumbHashToDataURL } from '/share/static/thumbhash/thumbhash.js'
* @property {boolean} [showArrows]
* @property {boolean} [showDownload]
* @property {boolean} [mobileArrows]
* @property {Record<string, any>} [options]
*/
/**
@@ -667,15 +668,18 @@ function buildDataSource () {
}
function initLightbox () {
const { options = {} } = lightboxConfig;
lightbox = new PhotoSwipeLightbox({
dataSource: buildDataSource(),
pswpModule: () => import('/share/static/photoswipe/photoswipe.esm.js'),
bgOpacity: 1,
showHideAnimationType: 'fade',
closeOnVerticalDrag: true,
arrowKeys: true,
loop: false,
padding: { top: 56, bottom: 56, left: 16, right: 16 }
padding: { top: 56, bottom: 56, left: 16, right: 16 },
...options,
dataSource: buildDataSource(),
pswpModule: () => import('/share/static/photoswipe/photoswipe.esm.js')
})
// Download button (only registered if config enables it)
+2 -1
View File
@@ -179,7 +179,8 @@ class Render {
// Show download button only if downloading is allowed AND configured.
showDownload: downloadAllowed && !!getConfigOption('ipp.lightbox.showDownload', 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>
},
groupByDate
}
+1
View File
@@ -27,6 +27,7 @@ export interface LightboxConfig {
showArrows: boolean
showDownload: boolean
mobileArrows: boolean
options?: Record<string, unknown>
}
export interface GalleryProps {