Images & Media

Upload once, request any size from a template

ImageWorks transforms images on request — width, height, fit, format, quality, effects — and caches the result on disk. There is no export step and no second copy to keep in sync.

ImageWorks is the image processing engine inside Total CMS. You upload one original, and every size and format a template needs is produced from it on request by passing a parameter array to cms.media.imagePath(), cms.media.galleryPath() or cms.render.image(). Transformed images are cached on disk, and when the source image changes the cached versions regenerate on the next request.

Resizing takes w, h, dpr and a fit mode. contain fits inside the box, max does the same without upscaling, fill fills and crops as needed, stretch distorts to exact dimensions, and crop crops to them. crop-{position} anchors the crop to one of nine positions, and crop-focalpoint crops around the focal point an editor set on that image in the admin — which is how a portrait survives being cropped into a wide banner.

Format and quality are fm and q: JPEG, PNG, GIF, WebP or AVIF, at whatever quality you name. Alongside them sit effects and adjustments — blur, sharpen, pixelate, a greyscale or sepia filter, brightness, contrast and gamma — plus borders, flipping and orientation. Every image also carries an automatically extracted palette of up to five colours, referenced as palette0 through palette4 in the border and bg parameters, so a letterboxed image can sit on its own dominant colour.

Repetition belongs in configuration rather than in your templates. imageworks.defaults in tcms.php applies parameters to every transformation on the site — set the format to WebP and the quality to 85 once, and everything is served that way, with anything passed in a template still winning. imageworks.presets names reusable parameter sets, called with {p: 'thumbnail'} and overridable inline, and a preset whose fit is crop-focalpoint uses each image's own focal point automatically.

In practice a card grid asks for {p: 'thumbnail'}, the article header asks for a 1600-pixel WebP, and the social share image asks for a hard 1200 by 630 crop — all three from the same upload, each one cached after its first request. They are served from the public /imageworks/ endpoint, though you rarely need to build one of those URLs by hand.

What you get

Fit modes, focal point included

contain, max, fill, stretch and crop, plus a crop anchored to any of nine positions or to the focal point an editor set in the admin.

Modern formats on request

Ask for WebP or AVIF with fm, set quality with q, and let a site-wide default apply both without touching a single template.

Presets and defaults

Name a parameter set in tcms.php and call it with {p: 'hero'}. Defaults apply everywhere, and values passed inline still take precedence.

Cached automatically

Every transformation is written to disk and reused. When the source image changes, the cached versions regenerate on the next request.

Colours from the image

Each image carries an extracted palette of up to five colours, usable as palette0 to palette4 in border and background parameters.

In practice

One snippet

<img src="{{ cms.media.imagePath('hero', {w: 800, h: 600, fit: 'crop'}) }}">

{# Crop using the focal point set in the admin #}
{{ cms.media.imagePath('portrait', {w: 300, h: 300, fit: 'crop-focalpoint'}) }}

One original, two requests. Both results are cached on disk after the first hit.

FAQ

Common questions

Is the image reprocessed on every request?

No. Each transformation is cached on disk in a .cache directory within the image storage directory and reused until the source image changes.

Can I set a site-wide format or quality?

Yes. imageworks.defaults in tcms.php applies parameters to every transformation, and anything passed in a template overrides them.

What is a focal point for?

It is a point on the image that an editor sets in the admin. Any crop using fit: 'crop-focalpoint' keeps that point in frame, so one photo crops well into both a square and a wide banner.

Which edition includes ImageWorks?

Image processing is not edition-gated. ImageWorks is available in Standard and Pro, watermarking included.