#27 fix issue with description on lazy loaded images

This commit is contained in:
Alan Grainger
2025-05-09 21:47:39 +12:00
parent ea5889f7a6
commit 2bba8d7527
6 changed files with 24 additions and 48 deletions
+2 -2
View File
@@ -2,9 +2,9 @@
<p align="center" width="100%"> <p align="center" width="100%">
<a href="https://hub.docker.com/r/alangrainger/immich-public-proxy/tags"> <a href="https://hub.docker.com/r/alangrainger/immich-public-proxy/tags">
<img alt="Docker pulls" src="https://badgen.net/docker/pulls/alangrainger/immich-public-proxy?v1.11.0&icon=docker&label=docker%20pulls&color=green&scale=1.1"></a> <img alt="Docker pulls" src="https://badgen.net/docker/pulls/alangrainger/immich-public-proxy?v1.11.1&icon=docker&label=docker%20pulls&color=green&scale=1.1"></a>
<a href="https://github.com/alangrainger/immich-public-proxy/releases/latest"> <a href="https://github.com/alangrainger/immich-public-proxy/releases/latest">
<img alt="Latest release" src="https://badgen.net/github/release/alangrainger/immich-public-proxy?v1.11.0&scale=1.1"></a> <img alt="Latest release" src="https://badgen.net/github/release/alangrainger/immich-public-proxy?v1.11.1&scale=1.1"></a>
<a href="https://immich-demo.note.sx/share/gJfs8l4LcJJrBUpjhMnDoKXFt1Tm5vKXPbXl8BgwPtLtEBCOOObqbQdV5i0oun5hZjQ"><img alt="Open demo gallery" src="https://badgen.net/static/↗🖼️/live%20demo/green?scale=1.1"></a> <a href="https://immich-demo.note.sx/share/gJfs8l4LcJJrBUpjhMnDoKXFt1Tm5vKXPbXl8BgwPtLtEBCOOObqbQdV5i0oun5hZjQ"><img alt="Open demo gallery" src="https://badgen.net/static/↗🖼️/live%20demo/green?scale=1.1"></a>
</p> </p>
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "immich-public-proxy", "name": "immich-public-proxy",
"version": "1.11.0", "version": "1.11.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "immich-public-proxy", "name": "immich-public-proxy",
"version": "1.11.0", "version": "1.11.1",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"dependencies": { "dependencies": {
"archiver": "^7.0.1", "archiver": "^7.0.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "immich-public-proxy", "name": "immich-public-proxy",
"version": "1.11.0", "version": "1.11.1",
"scripts": { "scripts": {
"dev": "ts-node src/index.ts", "dev": "ts-node src/index.ts",
"build": "npx tsc", "build": "npx tsc",
+1 -9
View File
@@ -64,15 +64,7 @@ class LGallery {
this.items this.items
.slice(this.index, this.index + PER_PAGE) .slice(this.index, this.index + PER_PAGE)
.forEach(item => { .forEach(item => {
if (item.video) { this.element.insertAdjacentHTML('beforeend', item)
this.element.insertAdjacentHTML('beforeend', `<a data-video='${item.video}'
${item.downloadUrl ? 'data-download-url="' + item.downloadUrl + '"' : ''}>
<img alt="" src="${item.thumbnailUrl}"/><div class="play-icon"></div></a>`)
} else {
this.element.insertAdjacentHTML('beforeend', `<a href="${item.previewUrl}"
${item.downloadUrl ? 'data-download-url="' + item.downloadUrl + '"' : ''}>
<img alt="" src="${item.thumbnailUrl}"/></a>`)
}
}) })
this.index += PER_PAGE this.index += PER_PAGE
this.lightGallery.refresh() this.lightGallery.refresh()
+16 -7
View File
@@ -117,13 +117,22 @@ class Render {
// Add a download link for the original-size image, if configured in config.json // Add a download link for the original-size image, if configured in config.json
downloadUrl = immich.photoUrl(share.key, asset.id, ImageSize.original) downloadUrl = immich.photoUrl(share.key, asset.id, ImageSize.original)
} }
items.push({
previewUrl: immich.photoUrl(share.key, asset.id, ImageSize.preview), const thumbnailUrl = baseUrl + immich.photoUrl(share.key, asset.id, ImageSize.thumbnail)
downloadUrl, const previewUrl = immich.photoUrl(share.key, asset.id, ImageSize.preview)
thumbnailUrl: baseUrl + immich.photoUrl(share.key, asset.id, ImageSize.thumbnail), const description = getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string' ? asset.exifInfo.description.replace(/'/g, '&apos;') : ''
video,
description: getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string' ? asset.exifInfo.description : '' // Create the full HTML element source to pass to the gallery view
}) const itemHtml = [
video ? `<a data-video='${video}'` : `<a href="${previewUrl}"`,
downloadUrl ? ` data-download-url="${downloadUrl}"` : '',
description ? ` data-sub-html='<p>${description}</p>'` : '',
`><img alt="" src="${thumbnailUrl}"/>`,
video ? '<div class="play-icon"></div>' : '',
'</a>'
].join('')
items.push(itemHtml)
} }
res.render('gallery', { res.render('gallery', {
items, items,
+2 -27
View File
@@ -32,33 +32,8 @@
<% <%
// Load the first 50 thumbnails, then load more as the user scrolls. See web.js // Load the first 50 thumbnails, then load more as the user scrolls. See web.js
items.slice(0, 50).forEach(item => { items.slice(0, 50).forEach(item => {
// Replace HTML entities for description text (if any) %><%- item %>
item.description = item.description.replace(/'/g, '&apos;') <% }) %>
if (item.video) { %>
<a data-video='<%- item.video %>'
<% if (item.description) { %>
data-sub-html='<p><%= item.description %></p>'
<% } %>
<% if (item.downloadUrl) { %>
data-download-url="<%- item.downloadUrl %>"
<% } %>
>
<img alt="" src="<%- item.thumbnailUrl %>"/>
<div class="play-icon"></div>
</a>
<% } else { %>
<a href="<%- item.previewUrl %>"
<% if (item.description) { %>
data-sub-html='<p><%= item.description %></p>'
<% } %>
<% if (item.downloadUrl) { %>
data-download-url="<%- item.downloadUrl %>"
<% } %>
>
<img alt="" src="<%- item.thumbnailUrl %>"/>
</a>
<% }
}) %>
</div> </div>
<script src="/share/static/web.js"></script> <script src="/share/static/web.js"></script>
<script src="/share/static/lg/lightgallery.min.js"></script> <script src="/share/static/lg/lightgallery.min.js"></script>