Skip to content

Commit

Permalink
Fix issue with video downloads and file names
Browse files Browse the repository at this point in the history
  • Loading branch information
alangrainger committed Nov 18, 2024
1 parent b9456af commit f974fc7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "immich-public-proxy",
"version": "1.5.0",
"version": "1.5.1",
"scripts": {
"dev": "ts-node src/index.ts",
"build": "npx tsc",
Expand Down
8 changes: 7 additions & 1 deletion app/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class Render {
})
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
if (data.status >= 200 && data.status < 300) {
// Populate the whitelisted response headers
Expand Down Expand Up @@ -97,7 +102,8 @@ class Render {
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
downloadUrl = immich.photoUrl(share.key, asset.id, ImageSize.original, asset.password)
}
Expand Down
6 changes: 5 additions & 1 deletion app/views/gallery.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
<div id="lightgallery">
<% items.forEach(item => {
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 %>"/>
<div class="play-icon"></div>
</a>
Expand Down

0 comments on commit f974fc7

Please sign in to comment.