Prepping for v3.0 release

Fetch album assets from timeline endpoint is the major change
This commit is contained in:
Alan Grainger
2026-06-22 06:21:51 +12:00
parent e50d5711fc
commit 494fbe36c7
18 changed files with 808 additions and 117 deletions
+17 -8
View File
@@ -49,13 +49,13 @@ export async function gallery (res: Response, share: SharedLink, openItem?: numb
const items: GalleryItem[] = await Promise.all(share.assets.map(async (asset): Promise<GalleryItem> => {
let videoData: string | undefined
if (asset.type === AssetType.video) {
const source: { src: string, type?: string } = { src: videoUrl(share.key, asset.id) }
// Album "grid" videos defer the content-type probe (one upstream call
// per video) - a <source> with no type lets the browser fall back to
// the proxy's response Content-Type, keeping grid render O(buckets).
if (!asset.needsDetail) source.type = await getVideoContentType(asset)
videoData = JSON.stringify({
source: [
{
src: videoUrl(share.key, asset.id),
type: await getVideoContentType(asset)
}
],
source: [source],
attributes: {
playsinline: 'playsinline',
controls: 'controls'
@@ -105,10 +105,18 @@ export async function gallery (res: Response, share: SharedLink, openItem?: numb
height,
thumbhash: asset.thumbhash,
fileCreatedAt: asset.fileCreatedAt,
exif: shareMetadataAllowed ? pickExif(asset) : undefined
exif: shareMetadataAllowed ? pickExif(asset) : undefined,
// Album grid items carry no exif / description / real filename yet; the
// client fetches them from `metaBase` the first time the item opens.
needsDetail: asset.needsDetail || undefined
}
}))
// Album shares contain lazy items; expose the on-demand metadata route so
// the client can fetch per-asset detail on lightbox open. Individual shares
// bake everything in, so no metaBase is needed there.
const metaBase = items.some(item => item.needsDetail) ? '/share/meta/' + share.key : undefined
const downloadAllowed = canDownload(share)
// Prefer the album's owner-chosen cover for og:image; fall back to first
// item if the cover asset has been filtered out (e.g. trashed).
@@ -144,7 +152,8 @@ export async function gallery (res: Response, share: SharedLink, openItem?: numb
sidebarHasContent,
locationWebLink: !!getConfigOption('ipp.showMetadata.location.webLink', true)
},
groupByDate
groupByDate,
metaBase
}
res.send(renderPage(h(Gallery, props)))
+40
View File
@@ -0,0 +1,40 @@
import { Asset, ImageSize, SharedLink } from '../types'
import { AssetMetadata } from '../shared/types'
import { getConfigOption } from '../config/access'
import { requiresOriginal } from '../immich'
import { pickExif } from './exif'
import { getFilename } from './filename'
/**
* Build the on-demand metadata payload for a single asset, served by the
* `/meta/` route when a lazy album item opens in the lightbox.
*
* This is the lazy-flow counterpart to the per-item baking the gallery
* builder does eagerly for individual shares: it applies the same
* `showMetadata` kill-switch and `ipp.showMetadata.*` gating, so the client
* never receives anything the operator hasn't opted into.
*/
export function buildAssetMetadata (asset: Asset, share: SharedLink): AssetMetadata {
// The share owner's "Show metadata" toggle is a kill-switch over the
// operator's own config - mirrors gallery/builder.ts.
const shareMetadataAllowed = share.showMetadata !== false
const descriptionInCaption = shareMetadataAllowed && !!getConfigOption('ipp.showMetadata.description.caption', false)
const descriptionInSidebar = shareMetadataAllowed && !!getConfigOption('ipp.showMetadata.description.sidebar', false)
const descriptionEnabled = descriptionInCaption || descriptionInSidebar
const description = descriptionEnabled && typeof asset?.exifInfo?.description === 'string'
? asset.exifInfo.description
: undefined
// Match the gallery builder's download-size resolution so the filename's
// extension reflects the bytes the user will actually receive.
const downloadServedSize = (getConfigOption('ipp.downloadOriginalPhoto', true) || requiresOriginal(asset))
? ImageSize.original
: ImageSize.preview
return {
exif: shareMetadataAllowed ? pickExif(asset) : undefined,
description,
downloadFilename: getFilename(asset, downloadServedSize)
}
}