#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
@@ -1,12 +1,12 @@
{
"name": "immich-public-proxy",
"version": "1.11.0",
"version": "1.11.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "immich-public-proxy",
"version": "1.11.0",
"version": "1.11.1",
"license": "AGPL-3.0",
"dependencies": {
"archiver": "^7.0.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "immich-public-proxy",
"version": "1.11.0",
"version": "1.11.1",
"scripts": {
"dev": "ts-node src/index.ts",
"build": "npx tsc",
+1 -9
View File
@@ -64,15 +64,7 @@ class LGallery {
this.items
.slice(this.index, this.index + PER_PAGE)
.forEach(item => {
if (item.video) {
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.element.insertAdjacentHTML('beforeend', item)
})
this.index += PER_PAGE
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
downloadUrl = immich.photoUrl(share.key, asset.id, ImageSize.original)
}
items.push({
previewUrl: immich.photoUrl(share.key, asset.id, ImageSize.preview),
downloadUrl,
thumbnailUrl: baseUrl + immich.photoUrl(share.key, asset.id, ImageSize.thumbnail),
video,
description: getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string' ? asset.exifInfo.description : ''
})
const thumbnailUrl = baseUrl + immich.photoUrl(share.key, asset.id, ImageSize.thumbnail)
const previewUrl = immich.photoUrl(share.key, asset.id, ImageSize.preview)
const description = getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string' ? asset.exifInfo.description.replace(/'/g, '&apos;') : ''
// 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', {
items,
+2 -27
View File
@@ -32,33 +32,8 @@
<%
// Load the first 50 thumbnails, then load more as the user scrolls. See web.js
items.slice(0, 50).forEach(item => {
// Replace HTML entities for description text (if any)
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>
<% }
}) %>
%><%- item %>
<% }) %>
</div>
<script src="/share/static/web.js"></script>
<script src="/share/static/lg/lightgallery.min.js"></script>