#200 motion photo (Live Photo) support

Show a badge on the gallery thumbnail and a lightbox toggle that plays the
photo's clip over the still, matching Immich's own viewer.

The clip is a hidden Immich asset, but the existing share key already
authorises it - checkSharedLinkAccess whitelists each shared asset's
livePhotoVideoId - so no new upstream access is involved. The video route
accepts a clip id only when a shared still points at it.

Both enumeration paths already carry the field (AssetResponseDto for
individual shares, TimeBucketAssetResponseDto for album buckets), so album
shares cost no extra upstream requests.

Gated by ipp.motionPhotos (default true). The clip is preload="none" and is
only fetched when a visitor presses the toggle.
This commit is contained in:
trecoool
2026-08-24 14:35:28 +02:00
parent 8c2c2219ce
commit 4021c66cec
17 changed files with 384 additions and 23 deletions
+12 -5
View File
@@ -1,12 +1,12 @@
// Per-tile DOM construction: anchor, image, thumbhash blur background, video
// play icon, selection checkmark, click + long-press handlers.
// play icon, motion-photo badge, selection checkmark, click + long-press.
// Runtime URL resolved by Express static, not a TS-resolvable module path.
// @ts-expect-error - browser-only ESM URL
import { thumbHashToDataURL } from '/share/static/thumbhash/thumbhash.js' // eslint-disable-line import/no-absolute-path
import { state, LONG_PRESS_MS } from './state.js'
import { CHECK_SVG } from './icons.js'
import { CHECK_SVG, ICON_MOTION_BADGE } from './icons.js'
import { enterSelectMode, toggleSelection } from './selection.js'
import { openLightbox } from './lightbox.js'
@@ -39,9 +39,9 @@ function decodeThumbhash (base64: string): string | null {
* Positioning is taken from the precomputed `state.layout`.
*
* The tile shows the thumbhash blur as a background, an `<img>` whose `src`
* is held back until the tile enters the viewport (see
* `loadVisibleTiles`), a play overlay for videos, and a selection
* checkmark + long-press handler if the share allows downloads.
* is held back until the tile enters the viewport (see `loadVisibleTiles`),
* a play overlay for videos, a corner badge for motion photos, and a
* selection checkmark + long-press handler if the share allows downloads.
*
* Click opens the lightbox unless selection mode is active, in which case
* it toggles the item's selection.
@@ -82,6 +82,13 @@ export function createTile (index: number): HTMLAnchorElement {
a.appendChild(playIcon)
}
if (item.motionUrl) {
const motion = document.createElement('div')
motion.className = 'motion-icon'
motion.innerHTML = ICON_MOTION_BADGE
a.appendChild(motion)
}
// Selection checkmark (rendered only when select mode is even possible -
// i.e. when the page included the toolbar element)
if (state.toolbarEl) {