FeaturesImages & 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.

Standard Included in Standard and Pro

Resize, Crop and Watermark Images in Your CMS (One Upload)
Resize, Crop and Watermark Images in Your CMS (One Upload)

ImageWorks is the image engine inside Total CMS. Upload one original, and every size and format a template needs is made from it on request, then cached on disk until the source image changes.

Ask for what the template needs

Pass a parameter array to cms.media.imagePath(), cms.media.galleryPath() or cms.render.image():

  • Size and fit. w, h and dpr set the size, and fit the shape: 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.
  • Crops that keep the subject. crop-{position} anchors a crop to one of nine positions. crop-focalpoint crops around the focal point an editor set in the admin, which is how a portrait survives being cropped into a wide banner.
  • Format and quality. fm serves JPEG, PNG, GIF, WebP or AVIF, and q sets the quality.
  • Effects. Blur, sharpen, pixelate, a greyscale or sepia filter, brightness, contrast and gamma, plus borders, flipping and orientation.
  • Colours from the image. Every image carries an extracted palette of up to five colours, palette0 to palette4, usable in border and bg, so a letterboxed image can sit on its own dominant colour.

Responsive images in one call

cms.render.picture() writes a whole <picture>: AVIF and WebP sources, each with a srcset of widths from 480 to 1920 pixels, and an <img> fallback in the image's own format.

  • Never upscaled. Widths wider than the original are dropped, and the original's own width joins as the largest.
  • Tell it the layout. sizes narrows what the browser downloads for an image that never spans the screen.
  • Dark mode. dark or darkProperty names a second image for prefers-color-scheme: dark, and the browser swaps it with no CSS or JavaScript.

Set it once, not in every template

  • Site-wide defaults. imageworks.defaults in tcms.php applies to every transformation. Set WebP at quality 85 once, and anything passed in a template still wins.
  • Named presets. imageworks.presets names reusable parameter sets, called with {p: 'thumbnail'} and overridable inline. A preset whose fit is crop-focalpoint uses each image's own focal point.
  • Warm the cache ahead of time. tcms imageworks:warm makes the files before the first visitor asks for them, after an import, a deploy or a launch. It skips files that already exist, so it is safe in a deploy script or a cron job, and --dry-run counts the files first.

Safe on a public URL

Images are served from the public /imageworks/ endpoint, so a request has limits:

  • Bad values are refused. A width over 10,000 or a quality over 100 gets a 400, and no image work is done.
  • Sizes can round up. Set Round Image Sizes to a step such as 50 and w=333 serves the 350-pixel file, so a bot asking for every width from 1 to 2000 cannot make 2000 files. It is off by default.
  • Renders wait in line. Only two new renders per CPU core run at once. Others wait up to 30 seconds, then get a 503 with Retry-After. Cached images never wait.

Watermarks are drawn by ImageWorks too, and on Pro so are layered marks such as the title on a share card: Watermarking covers both.

In practice

What it looks like in a template

twig
<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.

At a glance

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.

ImageWorks

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, with logo and text watermarks included. Layered marks, such as colour fills, wrapped titles and the share card overlays built on them, are Pro.

Try it on a site of your own.

45 days, every Pro feature, no credit card. Build it, hand it to a client, and see what they can and can’t touch.