diff --git a/app/public/photoswipe-overrides.css b/app/public/photoswipe-overrides.css index 9e48e82..31d04f7 100644 --- a/app/public/photoswipe-overrides.css +++ b/app/public/photoswipe-overrides.css @@ -45,7 +45,11 @@ color: var(--pswp-icon-color); } - +/* The zoom, counter, and close buttons are suppressed via PhotoSwipe options + (counter/zoom/close: false in client/lightbox.ts) so they can be re-enabled + through ipp.lightbox.options, rather than being hidden here in CSS. We use a + top-left back arrow (registered as `back-button` in client/lightbox-ui.ts) + in place of the close button, matching Immich's native asset-viewer. */ .pswp__button--download-button { color: #fff; diff --git a/app/src/client/lightbox.ts b/app/src/client/lightbox.ts index 5462896..147a619 100644 --- a/app/src/client/lightbox.ts +++ b/app/src/client/lightbox.ts @@ -82,14 +82,24 @@ function buildDataSource () { export function initLightbox () { const { options = {} } = state.lightboxConfig - // Extract padding to use as defaults, and paddingFn to avoid overwriting our function with an object from JSON - const { padding, paddingFn: _ignoredPaddingFn, ...restOptions } = options as any + // Pull `padding` out as an override. Drop any `paddingFn` coming from config + // without overwriting ours: PhotoSwipe expects a function there, so an object + // from JSON would crash it. + const configPadding = options.padding as Partial> | undefined + const restOptions = { ...options } + delete restOptions.padding + delete restOptions.paddingFn + // Full-bleed by default, the same as Immich. Reserve a bottom strip only when captions + // are enabled, so the caption has somewhere to sit without overlapping the image. + // Operators can override these via ipp.lightbox.options.padding + const showCaption = !!state.metadataConfig.descriptionInCaption const basePadding = { - top: padding?.top ?? 56, - bottom: padding?.bottom ?? 56, - left: padding?.left ?? 16, - right: padding?.right ?? 16 + top: 0, + bottom: showCaption ? 56 : 0, + left: 0, + right: 0, + ...configPadding } state.lightbox = new PhotoSwipeLightbox({ diff --git a/docs/configuration.md b/docs/configuration.md index 353942c..266c2d7 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -102,13 +102,13 @@ Example: show the gallery title and group photos by month. The gallery's lightbox is powered by [PhotoSwipe](https://photoswipe.com/). Configured under `ipp.lightbox`. -| Option | Type | Description | -|----------------|----------|------------------------------------------------------------------------------------------------------------------------------------------| -| `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. | -| `autoPlayVideos` | `bool` | Automatically play videos when their slide opens or becomes active. If the browser blocks unmuted autoplay (e.g. when deep-linking straight to a video), playback falls back to muted. Default `false`. | -| `options` | `object` | Custom [PhotoSwipe options](https://photoswipe.com/options/) to override defaults (e.g. `{"wheelToZoom": true}`). | +| Option | Type | Description | +|------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `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. | +| `autoPlayVideos` | `bool` | Automatically play videos when their slide opens or becomes active. If the browser blocks unmuted autoplay (e.g. when deep-linking straight to a video), playback falls back to muted. Default `false`. | +| `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.