Skip to content

Support PDF attachments with a first-page preview - #1166

Open
lylo wants to merge 3 commits into
mainfrom
pdf-attachments
Open

Support PDF attachments with a first-page preview#1166
lylo wants to merge 3 commits into
mainfrom
pdf-attachments

Conversation

@lylo

@lylo lylo commented Aug 11, 2026

Copy link
Copy Markdown
Owner

PDFs couldn't be attached to posts at all. Worksheets, papers and zines are exactly the sort of thing people want to hang off a post, and Lexxy already supports them end to end; the block was ours.

What changed

  • application/pdf joins UploadLimits::CONTENT_TYPES at 10MB, free tier, counting against the free quota like images. That one constant gates the editor, API, Micropub and posting by email.
  • A GeneratePdfPreviewJob renders the first page to a PNG once, triggered when the blob is attached, so all four ingress routes are covered. Requires pdftoppm (poppler), already on the server and now installed in CI; without it the job no-ops and the chip renders instead.
  • The blob partial renders a PDF as a first-page thumbnail with the caption, a Download link and file size beneath, all class-hooked so custom CSS can restyle or hide each part (documented in the help guide, unsynced). The partial previously emitted an empty <figure> for any non-media type, which also fed digest emails, both RSS feeds and exports.
  • Exports bundle storage-hosted links as well as images, so the PDF file lands in the zip. The figcaption Markdown converter now converts its children rather than flattening to text, so the Download link survives in Markdown exports.
  • The lightbox skips PDF thumbnails, and figure extension classes are downcased to match the editor (prod custom CSS audited, no uppercase selectors).

Behaviour changes

  • New posts can attach PDFs; existing content renders byte-identically apart from the downcased extension class.
  • The Download link opens the file in a new tab in production (cross-origin ignores the download attribute); a true attachment-disposition download is deliberately left for later.
  • PDFs cannot join image galleries; that's upstream in Lexxy (Dragging a PDF onto another PDF deletes it basecamp/lexxy#1235, #1236, #1237).

lylo added 2 commits August 11, 2026 07:52
PDFs join the upload allowlist at 10MB, free tier, counting against the
free quota like images. A background job renders the first page once via
the Poppler previewer, and the blog page shows it as a thumbnail with a
download link and file size beneath, all restylable from custom CSS.

The blob partial previously emitted an empty figure for anything that
wasn't image, video or audio, which also fed the digest emails, both RSS
feeds and exports. Exports now bundle storage-hosted links as well as
images, and the figcaption Markdown converter keeps links rather than
flattening them to text.
?post=<token> on the individual preview renders a specific post rather
than the latest, reusing its digest if one already exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant