Fix issue with video downloads and file names

This commit is contained in:
Alan Grainger 2024-11-18 14:18:13 +01:00
parent b9456afe5f
commit f974fc753f
3 changed files with 13 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "immich-public-proxy", "name": "immich-public-proxy",
"version": "1.5.0", "version": "1.5.1",
"scripts": { "scripts": {
"dev": "ts-node src/index.ts", "dev": "ts-node src/index.ts",
"build": "npx tsc", "build": "npx tsc",

View File

@ -53,6 +53,11 @@ class Render {
}) })
const data = await fetch(url, { headers }) const data = await fetch(url, { headers })
// Add the filename for downloaded assets
if (size === ImageSize.original && asset.originalFileName && getConfigOption('ipp.downloadOriginalPhoto', true)) {
res.setHeader('Content-Disposition', `attachment; filename="${asset.originalFileName}"`)
}
// Return the response to the client // Return the response to the client
if (data.status >= 200 && data.status < 300) { if (data.status >= 200 && data.status < 300) {
// Populate the whitelisted response headers // Populate the whitelisted response headers
@ -97,7 +102,8 @@ class Render {
controls: true controls: true
} }
}) })
} else if (asset.type === AssetType.image && getConfigOption('ipp.downloadOriginalPhoto', true)) { }
if (getConfigOption('ipp.downloadOriginalPhoto', true)) {
// 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, asset.password) downloadUrl = immich.photoUrl(share.key, asset.id, ImageSize.original, asset.password)
} }

View File

@ -21,7 +21,11 @@
<div id="lightgallery"> <div id="lightgallery">
<% items.forEach(item => { <% items.forEach(item => {
if (item.video) { %> if (item.video) { %>
<a data-video='<%- item.video %>'> <a data-video='<%- item.video %>'
<% if (item.downloadUrl) { %>
data-download-url="<%- item.downloadUrl %>"
<% } %>
>
<img alt="" src="<%- item.thumbnailUrl %>"/> <img alt="" src="<%- item.thumbnailUrl %>"/>
<div class="play-icon"></div> <div class="play-icon"></div>
</a> </a>