Image Transformations
In the admin: Settings › Features › Files
An image can be served resized, cropped or converted by adding parameters to its address. The original isn't touched.
GET /api/totalbase/table/files/{id}?width=400&format=webp
GET /api/totalbase/table/files/{id}?width=120&height=120&fit=cover
GET /api/totalbase/table/files/{id}?preset=thumbnail
The admin uses them itself: the list's thumbnails and the details preview are transformations, and the image editor builds its preview the same way.
Parameters
| Parameter | |
|---|---|
width, height | pixels. Images are never enlarged |
fit | cover, contain or inside |
format | jpeg, png, webp or avif |
quality | 1 to 100 |
rotate | 0, 90, 180 or 270 |
flip | horizontal or vertical |
cropLeft, cropTop, cropWidth, cropHeight | a crop, all four together |
grayscale, blur (0.3-100), sharpen | effects |
preset | a named set of parameters |
Presets
Named presets (JSON) in Settings › Features › Files gives a name to a set of parameters, so pages and emails ask for ?preset=thumbnail instead of repeating them:
{ "thumbnail": { "width": 150, "height": 150, "fit": "cover", "format": "webp" } }
Limits and caching
The same page sets the limits: maximum output width and height (4096 px), total pixels (16 million), operations per transformation (6), transformations at once (4) and a timeout (5 s). A result is cached for 30 days by default, in the browser and on the server, until an hourly cleanup.
| Error | When |
|---|---|
TRANSFORM_DISABLED | transformations are off |
TRANSFORM_NOT_APPLICABLE | the file isn't an image |
TRANSFORM_PRESET_NOT_FOUND | an unknown preset |
TRANSFORM_DIMENSIONS_TOO_LARGE | past the limits |
INVALID_TRANSFORM_PARAMS | a parameter out of range |
TRANSFORM_TIMEOUT, TRANSFORM_FAILED | the transformation didn't finish |