feat(media): unify uploads onto modules/album, add batched srcset enrichment and Media Library picker
This commit is contained in:
@@ -212,7 +212,8 @@ Every entry of `featured_images` (on `GET /posts`, `GET /posts/{slug}` and the a
|
||||
- **When they are made.** `POST /_journal/api/v1/posts/{id}/featured-images` stores the original and queues the conga job `golem15.journal.image_variants` (`classes.ImageVariantsArgs`, three attempts) after the row is written; the request itself never resizes or encodes, and a queue that cannot take the job is logged without failing the upload. An admin save of a post queues the job, after the save commits, for its featured images that lack a width.
|
||||
- **What is made.** For each width of `golem15.journal.image_widths` no larger than the original, `classes.GenerateImageVariants` writes the thumbnail (`attach.File.ThumbKey`, mode `exact`, the original's aspect ratio) and its WebP copy (`webp.Variant` of the framework's `modules/lagoon/attach/webp`). A width that has its row is skipped, so the job and the command can run any number of times. A missing or undecodable original, or one over the thumbnailer's 4096 by 4096 pixel limit, is skipped and logged.
|
||||
- **Backfill.** `journal:image-variants` takes the images that lack a width no larger than their original; `--all` checks every featured image. It runs from the application's CLI too: without a running server it opens `database.dsn` and `storage.uploads.bucket_url` itself.
|
||||
- **Not made.** AVIF (deferred). Images inserted into a post body keep their original file.
|
||||
- **Not made.** AVIF (deferred). Legacy `/uploads/...` images in a post body keep their original file untouched.
|
||||
- **Inline Media Library (`modules/album`) uploads & render-time `srcset` enrichment.** `POST /_journal/api/v1/media/upload` and the Blog Editor's direct image upload store new raster images through the framework's `modules/album` Media Library (into the virtual folder `journal`, or a sanitized subfolder beneath `journal`), generating synchronous WebP width variants (`480w`, `960w`, `1600w`) and returning `{data: {url, path, id, short_id, width, height, variants, srcset}}`. Stored post `content` and `content_html` remain clean `<img src="/media/<short-id>/<slug>.<ext>" ...>` tags. During `GET /_journal/api/v1/posts`, `GET /_journal/api/v1/posts/{slug}`, and `GET /_journal/api/v1/authors/{author}/posts` serialization, `classes.EnrichMediaHTML` enriches matching `/media/<short-id>/...` `<img>` tags in serialized `content_html` (and translations) with `srcset`, `sizes="(max-width: 768px) 100vw, 800px"`, and `width`/`height` using a single batched `WHERE short_id IN ?` query per request (zero N+1), while leaving legacy `/uploads/...` images byte-identical.
|
||||
- **Server.** WebP is encoded in Go. With the system libwebp installed (`libwebp.so` and `libwebpdemux.so`, Debian `libwebp-dev`) it is about five times faster. A binary that mounts this plugin is dynamically linked against glibc, unless it is built with `-tags nodynamic` (see the framework's attachments documentation).
|
||||
|
||||
### Personal API tokens
|
||||
|
||||
Reference in New Issue
Block a user