Allow custom transformations of assets (#6593)

* Allow custom transformations of assets

This exposes one query parameter `transforms`, which is a JSON array of
shard transformation operations.

It also updates the asset presets. The UX for this still needs some work

* Rename options to arguments for presets

More explicit

* options -> arguments in setting spec

* Better errors for invalid JSON in asset presets

* Add limit to transforms query parameter

* Use flattened option for extra transforms

* Fix placeholder color of code input

* Allow "simple mode" aliases

* Add documentation

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
Tim
2021-07-22 07:57:47 +12:00
committed by GitHub
parent 7dffa48570
commit 2c9ff3bca6
15 changed files with 387 additions and 118 deletions

View File

@@ -85,5 +85,34 @@ properties:
quality:
description: Quality of the compression used.
type: integer
format:
description: Reformat output image
type: string
enum:
- ''
- jpeg
- png
- webp
- tiff
transforms:
description: Additional transformations to apply
type: list
nullable: true
items:
type: object
properties:
method:
description: The Sharp method name
type: string
arguments:
description: A list of arguments to pass to the Sharp method
type: array
nullable: true
items:
type: object
properties:
argument:
description: A JSON representation of the argument value
type: string
example: null
nullable: true

View File

@@ -16,34 +16,11 @@ get:
description: The key of the asset size configured in settings.
schema:
type: string
- name: width
- name: transforms
in: query
description: Width of the file in pixels.
schema:
type: integer
- name: height
in: query
description: Height of the file in pixels.
schema:
type: integer
- name: fit
in: query
description: Fit of the file
description: A JSON array of image transformations
schema:
type: string
enum: [crop, contain, inside, outside]
- name: withoutEnlargement
in: query
description: No image upscale.
schema:
type: boolean
- name: quality
in: query
description: Quality of compression.
schema:
type: integer
minimum: 1
maximum: 100
- name: download
in: query
description: Download the asset to your computer