Language

Media library and automatic image tiers

Which tier a visitor gets is answered in one place, the media module; derivation has concurrency and pixel caps, skips instead of queueing and never retries, and oversized images have no traffic-saving tier.

After you upload an image, what visitors get is not necessarily the one you uploaded. The system automatically derives smaller tiers for images; list cards and the home-page carousel use the downscaled version, and only the detail page gets the original.

Who decides which tier a visitor sees

Only one place answers "is there a smaller tier": the media module. Themes and rendering paths take the address to ask it, and do not judge for themselves which addresses may have derived tiers.

This boundary is worth writing down, because "filtering it yourself" looks like less work: if a theme only asks about addresses of a certain path kind, then when the media module later recognizes one more address kind, the theme filters it out first — the feature quietly does not work, while the tests on both sides are green.

The two failures are deliberately different: when a link's derived artifact fails the check, the attribute is removed (keeping a link that jumps people to a broken place is worse than no link); when an image fails the check, the original address is kept (the author's uploaded image disappearing is worse than not saving traffic). An image never ends up with an empty address.

Derivation is not a requirement, and it does not queue

Decoding a 12M-pixel phone photo measured 64MB of memory and over a second in practice. If an operator drags in twenty at once, without constraints that is a dozen-plus 64MB happening simultaneously. So derivation has a concurrency cap (two at a time) and a pixel cap (16M); when no slot is available or the limit is exceeded, it is skipped, never queued.

Queuing would turn the upload response into "wait for the previous image to finish deriving" — jamming the backend for a traffic-saving optimization is putting the cart before the horse. Any step that fails only records one warning and lets the page fall back to the original image: rolling a successful upload back into an error for a pure optimization is the worst failure shape.

The cost, told honestly: a phone's direct-output image over 16M pixels has no traffic-saving tier, and both frontend and backend display the original.

Each image has only one cell for "has it been tried"

Derivation is a job, not a button you click once and wait for a result: the background task processes a few images per round, rotating kind by kind. Each asset has one cell recording "has this been tried", with three possible values — not tried, derived, skipped.

"Skipped" (animated images, PDFs, images already small, images over the pixel cap) is never retried. If "whether a derived row exists" were used as the criterion, these files would be re-decoded once every round. But a row that is "derived" yet has no tier at all must be re-picked, because an archive restore may only bring back the main table.

When visitors get the new tier after a change

The tier-switch result goes into that page's cache fingerprint, so a newly derived tier takes effect without you editing content.

What determines the type at upload

Type detection uses the sniffed MIME, not the file extension: an HTML renamed to .txt is judged as HTML. Business modules only receive media assets and never touch the filesystem.