From 32f209f1cdf4388df79ba0380e943c6761d8341b Mon Sep 17 00:00:00 2001
From: Alan Grainger <16197738+alangrainger@users.noreply.github.com>
Date: Tue, 26 May 2026 13:18:57 +0800
Subject: [PATCH] #227 add fullscreen button
---
app/public/web.js | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/app/public/web.js b/app/public/web.js
index ba3b2e5..f7a075e 100644
--- a/app/public/web.js
+++ b/app/public/web.js
@@ -82,8 +82,10 @@ const HEADER_HEIGHT = 48
// Vertical gap between groups
const GROUP_GAP = 16
-// MDI download icon (Apache 2.0). Same icon set Immich uses for its viewer.
+// MDI icons (Apache 2.0). Same icon set Immich uses for its viewer.
const ICON_DOWNLOAD = ''
+const ICON_FULLSCREEN = ''
+const ICON_FULLSCREEN_EXIT = ''
// ----- module state ---------------------------------------------------------
@@ -701,6 +703,42 @@ function initLightbox () {
})
}
+ // Fullscreen toggle. Skipped on browsers without Fullscreen API support
+ // for arbitrary elements (notably iOS Safari on iPhone).
+ if (document.fullscreenEnabled) {
+ lightbox.on('uiRegister', () => {
+ lightbox.pswp.ui.registerElement({
+ name: 'fullscreen-button',
+ order: 9,
+ isButton: true,
+ html: ICON_FULLSCREEN,
+ onInit: (el, pswp) => {
+ const update = () => {
+ const active = document.fullscreenElement === pswp.element
+ el.innerHTML = active ? ICON_FULLSCREEN_EXIT : ICON_FULLSCREEN
+ el.setAttribute('aria-label', active ? 'Exit fullscreen' : 'Fullscreen')
+ el.setAttribute('title', active ? 'Exit fullscreen' : 'Fullscreen')
+ }
+ update()
+ el.addEventListener('click', () => {
+ if (document.fullscreenElement) {
+ document.exitFullscreen().catch(() => {})
+ } else {
+ pswp.element.requestFullscreen().catch(() => {})
+ }
+ })
+ document.addEventListener('fullscreenchange', update)
+ pswp.on('destroy', () => {
+ document.removeEventListener('fullscreenchange', update)
+ if (document.fullscreenElement === pswp.element) {
+ document.exitFullscreen().catch(() => {})
+ }
+ })
+ }
+ })
+ })
+ }
+
// 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.