TotalBase
Files

Image Transformations

Resize, crop and convert images on the fly, by URL.

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, heightpixels. Images are never enlarged
fitcover, contain or inside
formatjpeg, png, webp or avif
quality1 to 100
rotate0, 90, 180 or 270
fliphorizontal or vertical
cropLeft, cropTop, cropWidth, cropHeighta crop, all four together
grayscale, blur (0.3-100), sharpeneffects
preseta 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.

ErrorWhen
TRANSFORM_DISABLEDtransformations are off
TRANSFORM_NOT_APPLICABLEthe file isn't an image
TRANSFORM_PRESET_NOT_FOUNDan unknown preset
TRANSFORM_DIMENSIONS_TOO_LARGEpast the limits
INVALID_TRANSFORM_PARAMSa parameter out of range
TRANSFORM_TIMEOUT, TRANSFORM_FAILEDthe transformation didn't finish

Next steps