explaingit

profilsoftware/wagtail-thumbnails

14PythonAudience · developerComplexity · 2/5ActiveLicenseSetup · moderate

TLDR

Python package for Wagtail and Django that serves responsive image variants from a StreamField block, with a JSON serializer that ships full HD, large, medium, and small WebP versions for headless frontends.

Mindmap

mindmap
  root((wagtail-thumbnails))
    Inputs
      Wagtail images
      StreamField content
      Project settings
    Outputs
      JSON image payload
      WebP variants
      Focal point data
    Use Cases
      Serve responsive images
      Validate uploads
      Migrate ImageChooserBlock
    Tech Stack
      Python
      Django
      Wagtail
      DRF

Things people build with this

USE CASE 1

Add a ThumbnailBlock to a Wagtail StreamField so editors can drop in images that auto-render at four responsive sizes.

USE CASE 2

Expose a Wagtail page through the API so a headless React or Next.js frontend can pick the right WebP variant per device.

USE CASE 3

Reject uploads smaller than a minimum width or height with a ValidationError before they reach the editor.

USE CASE 4

Migrate an existing site from ImageChooserBlock to ThumbnailBlock with a one-time data migration.

Tech stack

PythonDjangoWagtailDRFWebP

Getting it running

Difficulty · moderate Time to first run · 1h+

Targets Wagtail 6.3 or newer with Django 4.2 and DRF, and configuration errors raise at import time so the project must restart cleanly before pages render.

MIT license, free to use, modify, and redistribute including in commercial work, as long as the original copyright notice is kept.

In plain English

wagtail-thumbnails is a small Python package for sites built with Wagtail, an open-source content management system that runs on top of the Django web framework. The library helps developers serve images in several sizes at once, so that a headless frontend, meaning a separate JavaScript app that pulls data through an API, can pick the right image for the device it is rendering on. It targets projects that use Wagtail 6.3 or newer with Django 4.2 and Django REST Framework. The package adds a building block called ThumbnailBlock that editors can drop into a Wagtail StreamField, which is the area where content authors mix text, images, and other elements. When the page is read through the API, a matching serializer outputs a JSON object for each image: the original source URL, alt text resolved from editor input or the image description, the focal point if one was picked in the Wagtail admin, and a map of responsive variants. The defaults ship four variants named full_hd, large, medium, and small, each rendered as WebP with width, height, and format included in the payload. A settings dictionary called WAGTAIL_THUMBNAILS lets a project change the variant list, pick formats like webp, jpeg, or png, and set per-format quality. The same settings can enforce a minimum source width and height, or these checks can be skipped. Bad configuration values raise an error the first time they are read rather than at request time, which the author presents as a guardrail. There is also a validator pipeline. ThumbnailBlock accepts a list of callables that each receive an image and raise a Django ValidationError if the image fails a check. The default ImageResolutionValidator handles minimum width and height, and projects can add their own functions on top, for example to require landscape orientation. The README also explains how to migrate from the older ImageChooserBlock to the new ThumbnailBlock with a one-time data migration. The project is published on PyPI and is MIT licensed.

Copy-paste prompts

Prompt 1
Add wagtail-thumbnails to my Wagtail 6.3 project and configure WAGTAIL_THUMBNAILS to render only WebP at three variant sizes.
Prompt 2
Write a custom validator for ThumbnailBlock that requires landscape orientation and at least 1920px width.
Prompt 3
Show me the DRF serializer output for a page that uses ThumbnailBlock so I can wire it into a Next.js image component.
Prompt 4
Walk me through migrating my existing ImageChooserBlock fields to ThumbnailBlock without losing focal point data.
Prompt 5
Configure wagtail-thumbnails to skip the minimum source size check on legacy images and explain the trade-off.
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.