From d776bb826dcd3306f841b4101ebc496fe06571e2 Mon Sep 17 00:00:00 2001 From: e01 Date: Mon, 19 Oct 2020 20:56:14 +0300 Subject: [PATCH] Use withoutEnlargement for more consistency --- api/src/constants.ts | 2 +- api/src/controllers/assets.ts | 1 - api/src/database/seeds/03-fields/09-settings.yaml | 2 +- api/src/services/assets.ts | 4 ++-- api/src/types/assets.ts | 2 +- app/.storybook/mock-data/fields.json | 2 +- docs/guides/files.md | 3 ++- packages/spec/specs/components/setting.yaml | 2 +- packages/spec/specs/paths/assets/assets.yaml | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/api/src/constants.ts b/api/src/constants.ts index 0e6f62b393..ac1d7636aa 100644 --- a/api/src/constants.ts +++ b/api/src/constants.ts @@ -36,4 +36,4 @@ export const SYSTEM_ASSET_ALLOW_LIST: Transformation[] = [ }, ]; -export const ASSET_TRANSFORM_QUERY_KEYS = ['key', 'width', 'height', 'fit', 'noupscale']; +export const ASSET_TRANSFORM_QUERY_KEYS = ['key', 'width', 'height', 'fit', 'withoutEnlargement']; diff --git a/api/src/controllers/assets.ts b/api/src/controllers/assets.ts index af069df8d9..17c58815fa 100644 --- a/api/src/controllers/assets.ts +++ b/api/src/controllers/assets.ts @@ -117,7 +117,6 @@ router.get( res.attachment(file.filename_download); res.setHeader('Content-Type', file.type); - res.removeHeader('Content-Disposition'); if (req.query.hasOwnProperty('download') === false) { res.removeHeader('Content-Disposition'); diff --git a/api/src/database/seeds/03-fields/09-settings.yaml b/api/src/database/seeds/03-fields/09-settings.yaml index a9ab40b0cd..d2b3bddd07 100644 --- a/api/src/database/seeds/03-fields/09-settings.yaml +++ b/api/src/database/seeds/03-fields/09-settings.yaml @@ -172,7 +172,7 @@ fields: interface: numeric required: true width: half - - field: noupscale + - field: withoutEnlargement type: boolean schema: default_value: false diff --git a/api/src/services/assets.ts b/api/src/services/assets.ts index 81c059885f..c94e7f014c 100644 --- a/api/src/services/assets.ts +++ b/api/src/services/assets.ts @@ -51,8 +51,8 @@ export class AssetsService { if (transformation.width) resizeOptions.width = Number(transformation.width); if (transformation.height) resizeOptions.height = Number(transformation.height); if (transformation.fit) resizeOptions.fit = transformation.fit; - if (transformation.noupscale) - resizeOptions.withoutEnlargement = Boolean(transformation.noupscale); + if (transformation.withoutEnlargement) + resizeOptions.withoutEnlargement = Boolean(transformation.withoutEnlargement); return resizeOptions; } diff --git a/api/src/types/assets.ts b/api/src/types/assets.ts index 29a0fd036b..920acc6137 100644 --- a/api/src/types/assets.ts +++ b/api/src/types/assets.ts @@ -3,7 +3,7 @@ export type Transformation = { width?: number; // width height?: number; // height fit?: 'cover' | 'contain' | 'inside' | 'outside'; // fit - noupscale?: boolean; // Without Enlargement + withoutEnlargement?: boolean; // Without Enlargement }; // @NOTE Keys used in Transformation should match ASSET_GENERATION_QUERY_KEYS in constants.ts diff --git a/app/.storybook/mock-data/fields.json b/app/.storybook/mock-data/fields.json index ea2d8697c4..a21690a0d1 100644 --- a/app/.storybook/mock-data/fields.json +++ b/app/.storybook/mock-data/fields.json @@ -11391,7 +11391,7 @@ }, { "default_value": false, - "field": "noupscale", + "field": "withoutEnlargement", "interface": "toggle", "name": "No image upscale", "required": false, diff --git a/docs/guides/files.md b/docs/guides/files.md index 3d168fe12d..9bd3cf5ad4 100644 --- a/docs/guides/files.md +++ b/docs/guides/files.md @@ -44,7 +44,8 @@ Fetching thumbnails is as easy as adding query parameters to the original file's * **`width`** — The **width** of the thumbnail in pixels * **`height`** — The **height** of the thumbnail in pixels * **`quality`** — The **quality** of the thumbnail (`0` to `100`) -* **`noupscale`** — Disable image up-scaling +* **`withoutEnlargement`** — Disable image up-scaling +* **`download`** — Add `Content-Disposition` header and force browser to download file ``` example.com/assets/?fit=&width=&height=&quality= diff --git a/packages/spec/specs/components/setting.yaml b/packages/spec/specs/components/setting.yaml index c54b21f494..6fde821916 100644 --- a/packages/spec/specs/components/setting.yaml +++ b/packages/spec/specs/components/setting.yaml @@ -79,7 +79,7 @@ properties: height: description: Height of the thumbnail. type: integer - noupscale: + withoutEnlargement: description: No image upscale type: boolean quality: diff --git a/packages/spec/specs/paths/assets/assets.yaml b/packages/spec/specs/paths/assets/assets.yaml index 95a5fb9561..f01c392125 100644 --- a/packages/spec/specs/paths/assets/assets.yaml +++ b/packages/spec/specs/paths/assets/assets.yaml @@ -33,7 +33,7 @@ get: schema: type: string enum: [crop, contain, inside, outside] - - name: noupscale + - name: withoutEnlargement in: query description: No image upscale. schema: