linkImage makes thumbnails of PDF files
-
What you'll see
You list uploaded files - brochures, datasheets, reports - and want a preview of each document. The reference pages for
linkImageand the image-scaling articles only talk about images, so it is easy to conclude that a PDF needs a generic icon, a separate thumbnail you upload by hand, or a server-side conversion step. -
What's actually happening
Docly's image scaler accepts PDF files. A scaled URL on a PDF -
<file-url>/<embedded-id>/<W>x<H>x<M>/<name>.<ext>, built bylinkImage- returns the first page rendered as an image. The scaling modes behave as for images (1 fills and crops, 0 fits), and the extension on the display name chooses the format. Measured 2026-11-28 on an uploaded 671 KB brochure:160x200x1returned a 160×200 image as WebP (7.8 KB), JPEG (10 KB) and PNG (80 KB). The result is cached per size like any scaled image, and the size policy in#/images.jsonapplies.The Docly admin UI already uses the same rendering for PDF tiles in folder lists (see Preview image in folder lists).
-
What to do
Link the file like an image, with the row object from
getFilesas the first argument:#{ for (let f of docly.getFiles("/Documents")) { }# <a href="#docly.linkFile(f, f.File)#"> <img src="#docly.linkImage(f, f.File, 160, 200, 1, f.filename + '.webp')#" width="160" height="200" loading="lazy" alt="#docly.htmlAttributeEncode(f.Title)#"> </a> #{ } }#- For an Uploaded File document the embedded id is in the field
File. - Use one fixed thumbnail size and register it in
allowedSizesbefore you switch the size policy to strict. - Keep a file-type icon as fallback for files the scaler cannot render (docx, xlsx, zip).
- On a publication with a site router, check that scaled URLs pass through it (see The site router answers 500 on attachment and scaled-image URLs).
- For an Uploaded File document the embedded id is in the field
Last reviewed 28 Nov 2026