From eaf873ea28717e793ae58397edf76f8fc473cac0 Mon Sep 17 00:00:00 2001 From: Mark van der Feijst Date: Sun, 1 Sep 2024 21:22:10 +0200 Subject: [PATCH] docs: Add conditional album storage template information --- docs/docs/partials/_storage-template.md | 6 ++++++ server/src/constants.ts | 1 + server/src/services/system-config.service.spec.ts | 1 + 3 files changed, 8 insertions(+) diff --git a/docs/docs/partials/_storage-template.md b/docs/docs/partials/_storage-template.md index f48419c1ef7a6..b6dcd5ad7759c 100644 --- a/docs/docs/partials/_storage-template.md +++ b/docs/docs/partials/_storage-template.md @@ -27,3 +27,9 @@ If an asset is in multiple albums, `{{album}}` will be set to the name of the al ::: Immich also provides a mechanism to migrate between templates so that if the template you set now doesn't work in the future, you can always migrate all the existing files to the new template. The mechanism is run as a job on the Job page. + +If you want to store assets in album folders, but you also have assets that do not belong to any album, you can use `{{#if album}}`, `{{else}}` and `{{/if}}` to create a conditional statement. For example, the following template will store assets in album folders if they belong to an album, and in a folder named "Other/Month" if they do not belong to an album: + +``` +{{y}}/{{#if album}}{{album}}{{else}}Other/{{MM}}{{/if}}/{{filename}} +``` diff --git a/server/src/constants.ts b/server/src/constants.ts index 29ed5f6d37c85..6cfcc41d89ba6 100644 --- a/server/src/constants.ts +++ b/server/src/constants.ts @@ -75,6 +75,7 @@ export const supportedPresetTokens = [ '{{y}}/{{MM}}-{{dd}}/{{filename}}', '{{y}}/{{MMMM}}-{{dd}}/{{filename}}', '{{y}}/{{MM}}/{{filename}}', + '{{y}}/{{#if album}}{{album}}{{else}}Other/{{MM}}{{/if}}/{{filename}}', '{{y}}/{{MMM}}/{{filename}}', '{{y}}/{{MMMM}}/{{filename}}', '{{y}}/{{MM}}/{{dd}}/{{filename}}', diff --git a/server/src/services/system-config.service.spec.ts b/server/src/services/system-config.service.spec.ts index af2b564ab2fe8..409cd6a52f360 100644 --- a/server/src/services/system-config.service.spec.ts +++ b/server/src/services/system-config.service.spec.ts @@ -336,6 +336,7 @@ describe(SystemConfigService.name, () => { '{{y}}/{{MM}}-{{dd}}/{{filename}}', '{{y}}/{{MMMM}}-{{dd}}/{{filename}}', '{{y}}/{{MM}}/{{filename}}', + '{{y}}/{{#if album}}{{album}}{{else}}Other/{{MM}}{{/if}}/{{filename}}', '{{y}}/{{MMM}}/{{filename}}', '{{y}}/{{MMMM}}/{{filename}}', '{{y}}/{{MM}}/{{dd}}/{{filename}}',