1
0
Fork 0
mirror of https://github.com/alangrainger/immich-public-proxy.git synced 2025-04-17 05:26:27 +02:00

add og-image from the gallery's first thumbnail

This commit is contained in:
Alan Grainger 2025-03-24 17:00:06 +08:00
parent 8f7892a9d7
commit 0d3fc18f40
4 changed files with 19 additions and 5 deletions

4
app/package-lock.json generated
View file

@ -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",

View file

@ -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",

View file

@ -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
})
}

View file

@ -1,8 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title><%- title %></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<%
// Add an og-image using the first image's thumbnail
if (items?.[0]?.thumbnailUrl) {
%>
<meta property="og:image" content="<%- items[0].thumbnailUrl %>"/>
<% } %>
<link rel="icon" href="/share/static/favicon.ico" type="image/x-icon">
<link type="text/css" rel="stylesheet" href="/share/static/style.css"/>
<link type="text/css" rel="stylesheet" href="/share/static/lg/lightgallery-bundle.min.css"/>