Thumbnails
This guide explains how Blot selects, builds and exposes thumbnails for your entries. Use it when building index pages, entry cards, image grids or when you need thumbnails for social previews. For an overview of how Blot handles uploaded image files, see the image files guide.
Image files and thumbnails
A standalone image post uses its image as the source for its thumbnails. Blot does not compress or optimize the original image file; thumbnails are separate, resized images exposed to templates through the entry’s thumbnail object.
Which image is used as a thumbnail?
Blot builds a list of candidate images in a strict order:1
Thumbnailmetadata if present.- Images in the HTML generated from the file in document order.
- Video thumbnails from Vimeo or YouTube embeds.
Blot iterates those candidates in order and stops at the first one with the following properties:
- At least 64×64 pixels in size
- In a supported format:
png,jpeg,jpg,svg,gif, orwebp
How to override the thumbnail
If you are not happy with the image selected by default, you can set the Thumbnail metadata field to a path to an image in your folder or a full URL.
Thumbnail: ./cover.jpg
Thumbnail sizes
If there is an image that meets the criteria, Blot generates four thumbnail variants:
| Size | Max width and height | Notes |
|---|---|---|
| small | 160px | — |
| medium | 640px | — |
| large | 1200px | — |
| square | 160px | cropped |
When images are resized, Blot never increases the dimensions of the image. A source image smaller than a size limit remains at its original dimensions for that variant.2
How to use the thumbnail object in templates
Each entry exposes a thumbnail object (see the entry reference) with small, medium, large, and square variants. Each variant includes a url, width, and height.6
Minimal example:
{{#entry}}
{{#thumbnail.medium}}
<img src="{{{url}}}"
width="{{width}}"
height="{{height}}"
alt="{{title}}"
>
{{/thumbnail.medium}}
{{/entry}}
{
"entry": {
title: "Your title here",
thumbnail: {
medium: {
url: "https://cdn.blot.im/path/to/image.jpg",
width: 640,
height: 425
}
}
}
}
<img
src="https://cdn.blot.im/path/to/image.jpg"
width="640"
height="425"
alt="Your title here"
>
Guard with {{#thumbnail.medium}} and {{^thumbnail.medium}} so you avoid broken images and can show fallback UI when there is no thumbnail.
Responsive thumbnails
Blot’s album grid template uses srcset and sizes with the thumbnail widths to let the browser pick the right image.7 Below is a compact example for a three-column grid that collapses to two and then one. The sizes values should match your breakpoints.
<div class="grid">
{{#entries}}
{{#thumbnail.medium}}
<figure>
<img
src="{{{thumbnail.large.url}}}"
srcset="
{{{thumbnail.small.url}}} {{thumbnail.small.width}}w,
{{{thumbnail.medium.url}}} {{thumbnail.medium.width}}w,
{{{thumbnail.large.url}}} {{thumbnail.large.width}}w
"
sizes="
(max-width: 600px) 100vw,
(max-width: 900px) 50vw,
33vw
"
width="{{thumbnail.medium.width}}"
height="{{thumbnail.medium.height}}"
alt="{{title}}"
>
</figure>
{{/thumbnail.medium}}
{{/entries}}
</div>
.grid {
display: grid;
gap: 1.5rem;
grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 900px) {
.grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 600px) {
.grid {
grid-template-columns: 1fr;
}
}
In this example, sizes reports one column below 600px, two columns up to 900px and three columns above 900px. Keep the sizes values in sync with your CSS grid so the browser chooses the correct thumbnail width.
Implementation reference
- Thumbnail candidates and selection order:
app/build/thumbnail/candidates.js,app/build/thumbnail/index.js. - Thumbnail transformations and no-upscaling behavior:
app/build/thumbnail/transform.js. - Thumbnail validation rules and supported formats:
app/build/thumbnail/validate.js,app/build/thumbnail/config.js. - Thumbnail metadata guidance:
app/views/how/metadata.html. - Dependency resolution for thumbnail metadata paths:
app/build/dependencies/index.js. - Template reference for the thumbnail object:
app/views/developers/reference.yml. - Example usage of
srcsetandsizesin a grid template:app/templates/source/album/entries.html.