From 0d3fc18f40fdab77c38d536dee3c2c9c97d3a2bf Mon Sep 17 00:00:00 2001 From: Alan Grainger Date: Mon, 24 Mar 2025 17:00:06 +0800 Subject: [PATCH] #72 add og-image from the gallery's first thumbnail --- app/package-lock.json | 4 ++-- app/package.json | 2 +- app/src/render.ts | 10 +++++++++- app/views/gallery.ejs | 8 +++++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/package-lock.json b/app/package-lock.json index 28dab35..e6be723 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -1,12 +1,12 @@ { "name": "immich-public-proxy", - "version": "1.9.0", + "version": "1.9.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "immich-public-proxy", - "version": "1.9.0", + "version": "1.9.1", "license": "AGPL-3.0", "dependencies": { "archiver": "^7.0.1", diff --git a/app/package.json b/app/package.json index fecaa49..8bd39af 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "immich-public-proxy", - "version": "1.9.0", + "version": "1.9.1", "scripts": { "dev": "ts-node src/index.ts", "build": "npx tsc", diff --git a/app/src/render.ts b/app/src/render.ts index 88a861c..b702950 100644 --- a/app/src/render.ts +++ b/app/src/render.ts @@ -88,6 +88,14 @@ class Render { */ async gallery (res: Response, share: SharedLink, openItem?: number) { const items = [] + + // Originally I had the base URL as a config option in .env. + // The issue with that is people who may be wanting to route in via multiple + // public URLs. So instead we generate the base URL from the incoming request data. + // This may cause issues with some reverse proxies, in which case just make sure + // that you're sending the correct `host` header to IPP. + const baseUrl = res.req.protocol + '://' + res.req.headers.host + for (const asset of share.assets) { let video, downloadUrl if (asset.type === AssetType.video) { @@ -112,7 +120,7 @@ class Render { items.push({ previewUrl: immich.photoUrl(share.key, asset.id, ImageSize.preview), downloadUrl, - thumbnailUrl: immich.photoUrl(share.key, asset.id, ImageSize.thumbnail), + thumbnailUrl: baseUrl + immich.photoUrl(share.key, asset.id, ImageSize.thumbnail), video }) } diff --git a/app/views/gallery.ejs b/app/views/gallery.ejs index 2474eb7..ea385db 100644 --- a/app/views/gallery.ejs +++ b/app/views/gallery.ejs @@ -1,8 +1,14 @@ - <%- title %> + + <% + // Add an og-image using the first image's thumbnail + if (items?.[0]?.thumbnailUrl) { + %> + + <% } %>