Skip to content

Use image renditions for the editor's thumbnails - #242

Merged
ssavutu merged 1 commit into
mainfrom
feat/editor-image-variants
Oct 1, 2026
Merged

ssavutu merged 1 commit into
mainfrom
feat/editor-image-variants

Conversation

@ssavutu

@ssavutu ssavutu commented Oct 1, 2026

Copy link
Copy Markdown
Member

Why

The editor still draws every thumbnail from the original file. The library is mostly camera originals (often 5–80 MB), so the media grid downloads dozens of full-size photos to draw ~150px squares. The article list does the same for its 48px thumbnails. The API already sends resized renditions with these images (#239, #241), so the editor just needs to use them.

Change

  • lib/imageVariants.ts: an ImageVariant type and srcSetFor(). It returns undefined when there are no renditions, so the attribute is omitted, never empty.
  • srcSet + sizes on:
    • the media library grid (2–6 columns) and its detail preview (400px)
    • the media picker grid (2–5 columns)
    • the article list thumbnails (48px)
    • the featured-image preview in the editor (96px). Its renditions are stored with the URL they came with, because that URL can also be typed or pasted; a stale set is never shown against a different image. Only photo_url is saved, as before.
  • src stays the original everywhere, so images the backfill hasn't reached look exactly as they do now.
  • Not changed: images inserted into article bodies (trixImageHtml). Their URL is saved into the content and must stay the original. Readers get the renditions through content_image_variants (Return renditions for the images inside an article body #240).

Verified

  • vitest: 23/23, including new tests for srcSetFor (including the empty and missing cases) and a picker test checking a tile keeps the original as src and gets the renditions as srcset.
  • npm run build (tsc -b + vite) passes. eslint reports no new issues; the one exhaustive-deps warning in editArticleView.tsx is already on main.
  • Not exercised in a browser: the editor needs an OIDC login, which I don't have locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_019EcFyy8aqNnUd75CDPY6Bx

The media library grid, the media picker, the article list and the
featured-image preview all drew their thumbnails from the original file.
The library is mostly camera originals, so a page of the media grid
downloaded dozens of multi-megabyte photos to draw 150px squares. The API
now sends resized renditions with every library image and featured image.
These thumbnails pass them to the browser as a srcset, with `sizes`
matching each layout.

Images inserted into article bodies are untouched: their URL is saved into
the content, and that must stay the original.

The featured-image preview keeps its renditions alongside the URL they
belong to, because the URL can also be typed or pasted, and a stale set must
never be shown against a different image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019EcFyy8aqNnUd75CDPY6Bx
@ssavutu
ssavutu merged commit 50dcf74 into main Oct 1, 2026
7 checks passed
@ssavutu
ssavutu deleted the feat/editor-image-variants branch October 1, 2026 03:47
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