Use album cover for og:image
Co-authored-by: Pierre KELBERT <root@mout.ch>
This commit is contained in:
@@ -240,6 +240,7 @@ class Immich {
|
||||
}
|
||||
// Replace the empty link.assets array with the array of assets from the album
|
||||
link.assets = album.assets
|
||||
if (link.album) link.album.albumThumbnailAssetId = album.albumThumbnailAssetId
|
||||
}
|
||||
|
||||
link.password = password
|
||||
|
||||
@@ -280,6 +280,10 @@ class Render {
|
||||
}))
|
||||
|
||||
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).
|
||||
const coverId = share.album?.albumThumbnailAssetId
|
||||
const ogImageItem = (coverId && items.find(i => i.id === coverId)) || items[0]
|
||||
const props: GalleryProps = {
|
||||
items,
|
||||
title: this.title(share),
|
||||
@@ -289,6 +293,7 @@ class Render {
|
||||
showDownload: downloadAllowed,
|
||||
showTitle: !!getConfigOption('ipp.gallery.showTitle', true),
|
||||
openItem,
|
||||
ogImageItem,
|
||||
lightboxConfig: {
|
||||
// Show download button only if downloading is allowed AND configured.
|
||||
showDownload: downloadAllowed && !!getConfigOption('ipp.lightbox.showDownload', true),
|
||||
|
||||
@@ -42,6 +42,7 @@ export interface Asset {
|
||||
export interface Album {
|
||||
id: string;
|
||||
assets: Asset[];
|
||||
albumThumbnailAssetId?: string;
|
||||
}
|
||||
|
||||
export interface SharedLink {
|
||||
@@ -57,6 +58,7 @@ export interface SharedLink {
|
||||
albumName?: string;
|
||||
order?: string;
|
||||
description?: string;
|
||||
albumThumbnailAssetId?: string;
|
||||
}
|
||||
expiresAt: string | null;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ export interface GalleryProps {
|
||||
showDownload: boolean
|
||||
showTitle: boolean
|
||||
openItem?: number
|
||||
ogImageItem?: GalleryItem
|
||||
lightboxConfig: LightboxConfig
|
||||
groupByDate: boolean
|
||||
}
|
||||
@@ -50,11 +51,13 @@ export function Gallery (props: GalleryProps) {
|
||||
groupByDate: props.groupByDate
|
||||
})
|
||||
const firstItem = props.items[0]
|
||||
// For videos, previewUrl points to the .mp4; use thumbnailUrl so og:image is always a still JPEG.
|
||||
const ogImageAsset = firstItem
|
||||
? (firstItem.type === AssetType.video ? firstItem.thumbnailUrl : firstItem.previewUrl)
|
||||
// og:image prefers the album cover (passed via props); for videos, previewUrl
|
||||
// points to the .mp4, so use thumbnailUrl to keep og:image a still JPEG.
|
||||
const ogItem = props.ogImageItem || firstItem
|
||||
const ogImageAsset = ogItem
|
||||
? (ogItem.type === AssetType.video ? ogItem.thumbnailUrl : ogItem.previewUrl)
|
||||
: ''
|
||||
const ogImageUrl = firstItem ? props.publicBaseUrl + ogImageAsset : ''
|
||||
const ogImageUrl = ogItem ? props.publicBaseUrl + ogImageAsset : ''
|
||||
|
||||
return (
|
||||
<html lang="en">
|
||||
|
||||
Reference in New Issue
Block a user