#149 Add option to keep original filename when downloading

This commit is contained in:
Alan Grainger
2025-10-28 17:03:00 +08:00
parent 2f3fd7cacb
commit 0a19d8af7e
5 changed files with 14 additions and 4 deletions
+1
View File
@@ -151,6 +151,7 @@ Alternatively, you can [pass the configuration inline](docs/inline-configuration
| `responseHeaders` | `object` | Change the headers sent with your web responses. By default there is `cache-control` and CORS added. | | `responseHeaders` | `object` | Change the headers sent with your web responses. By default there is `cache-control` and CORS added. |
| `singleImageGallery` | `bool` | By default a link to a single image will directly open the image file. Set to `true` if you want to show a gallery page instead for a single item. | | `singleImageGallery` | `bool` | By default a link to a single image will directly open the image file. Set to `true` if you want to show a gallery page instead for a single item. |
| `downloadOriginalPhoto` | `bool` | Set to `false` if you only want people to be able to download the 'preview' quality photo, rather than your original photo. | | `downloadOriginalPhoto` | `bool` | Set to `false` if you only want people to be able to download the 'preview' quality photo, rather than your original photo. |
| `downloadedFilename` | `int` | The filename of the downloaded image.<br>`0` for the current time<br>`1` for the original filename<br>`2` for the Immich asset ID number |
| `showGalleryTitle` | `bool` | Show a title on the gallery page. | | `showGalleryTitle` | `bool` | Show a title on the gallery page. |
| `allowDownloadAll` | `int` | Allow visitors to download all files as a zip.<br>`0` disable downloads<br>`1` follow Immich setting per share ([example](https://github.com/user-attachments/assets/79ea8c08-71ce-42ab-b025-10aec384938a))<br>`2` always allowed | | `allowDownloadAll` | `int` | Allow visitors to download all files as a zip.<br>`0` disable downloads<br>`1` follow Immich setting per share ([example](https://github.com/user-attachments/assets/79ea8c08-71ce-42ab-b025-10aec384938a))<br>`2` always allowed |
| `allowSlugLinks` | `bool` | Enable/disable the custom URL links. | | `allowSlugLinks` | `bool` | Enable/disable the custom URL links. |
+1
View File
@@ -7,6 +7,7 @@
"singleImageGallery": false, "singleImageGallery": false,
"singleItemAutoOpen": true, "singleItemAutoOpen": true,
"downloadOriginalPhoto": true, "downloadOriginalPhoto": true,
"downloadedFilename": 0,
"allowDownloadAll": 0, "allowDownloadAll": 0,
"allowSlugLinks": true, "allowSlugLinks": true,
"showHomePage": true, "showHomePage": true,
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "immich-public-proxy", "name": "immich-public-proxy",
"version": "1.13.7", "version": "1.14.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "immich-public-proxy", "name": "immich-public-proxy",
"version": "1.13.7", "version": "1.14.0",
"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.13.7", "version": "1.14.0",
"scripts": { "scripts": {
"dev": "ts-node src/index.ts", "dev": "ts-node src/index.ts",
"build": "npx tsc", "build": "npx tsc",
+9 -1
View File
@@ -137,12 +137,20 @@ class Render {
const previewUrl = immich.photoUrl(share.key, asset.id, immich.getPreviewImageSize(asset)) const previewUrl = immich.photoUrl(share.key, asset.id, immich.getPreviewImageSize(asset))
const description = getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string' ? asset.exifInfo.description.replace(/'/g, '&apos;') : '' const description = getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string' ? asset.exifInfo.description.replace(/'/g, '&apos;') : ''
// Filename for the downloaded image
let filename = 'img_' + Date.now()
if (getConfigOption('ipp.downloadedFilename') === 1) {
filename = asset.originalFileName || filename
} else if (getConfigOption('ipp.downloadedFilename') === 2) {
filename = asset.id
}
// Create the full HTML element source to pass to the gallery view // Create the full HTML element source to pass to the gallery view
const itemHtml = [ const itemHtml = [
video ? `<a data-video='${video}'` : `<a href="${previewUrl}"`, video ? `<a data-video='${video}'` : `<a href="${previewUrl}"`,
downloadUrl ? ` data-download-url="${downloadUrl}"` : '', downloadUrl ? ` data-download-url="${downloadUrl}"` : '',
description ? ` data-sub-html='<p>${description}</p>'` : '', description ? ` data-sub-html='<p>${description}</p>'` : '',
`><img alt="" src="${thumbnailUrl}"/>`, ` data-download="${filename}"><img alt="" src="${thumbnailUrl}"/>`,
video ? '<div class="play-icon"></div>' : '', video ? '<div class="play-icon"></div>' : '',
'</a>' '</a>'
].join('') ].join('')