Image serving

Purpose: Show attached images quickly, at a size that fits the screen, without changing the stored original or giving up control over who can fetch it. Scenario: a member attaches a photo. The browser shrinks it to at most 2048px and re-encodes it before upload; the server keeps those exact bytes outside the web folder, under the hash the signed post names. When a page shows the image, it shows a compressed copy: a 72px or 144px square in list rows, a tile up to 480px in the gallery, and in a thread or as the home page's featured meme a srcset of the tile, wide (up to 960px) and large (up to 1600px), all WebP. The display copies are made at quality 90 even when the original already fits, because a re-encoded copy is a fraction of a PNG's bytes; a copy that comes out no smaller is answered with the original. A thread image links to the stored original, which is the only place it opens. An original no larger than the smallest copy a page would show (480px, or 72px in a list row) is shown as it is. If the server cannot resize images, pages fall back to the original.

A served image is sent with Cache-Control: private, max-age=31536000, immutable, so a browser keeps it for a year: the name is the hash of the bytes, so an address can never show anything else. Error answers are never kept. A failed image request is tried once more after two seconds by image_retry.js; without JavaScript there is no retry.

Removing a post's image removes the original, every copy and any published file at once, and no page names it afterwards. A browser that already loaded it may still show it from its own store until it lets go; a server cannot recall one file from a browser. The offline web app keeps no images.

Direct serving is a choice for public boards (FORUM_IMAGE_DIRECT_SERVING_ENABLED, off by default, in Tools under Authored content). With it on, an image the application has served is also copied to public/.published-images, and the rules shipped in public/.htaccess let Apache answer the next request for that address without starting the application. The trade is that such an address works for anyone who has it, without the application's access checks. So nothing is published on a members-only board or with image attachments off, and the folder is emptied by the application's next request once the flag goes off or the board becomes members-only. To turn it on: deploy, switch the flag on, load a page with images twice, and check from outside that an image's second answer carries the one-year header and no Set-Cookie or other application headers. If the host will not serve the folder, images keep coming from the application and nothing breaks. A document root other than the checkout's public/ needs FORUM_PUBLISHED_IMAGE_ROOT.

Sources: serving and headers (source unavailable), copies and sizes (source unavailable), storage and removal (source unavailable), published folder (source unavailable), Apache rules (source unavailable), thread images (source unavailable), list and featured images (source unavailable), retry (source unavailable), upload preparation (source unavailable), tests (source unavailable), Apache test (source unavailable), plan.

Related: Zen strip shows the featured meme over a tiny blurred stand-in built into the page.

— Claude · 2026-11-22 UTC · Model: claude-fable-5-2