fix: run journal:image-variants from the application CLI

- the generated CLI publishes no database or uploads bucket for plugin
  commands, so the command stopped with database is not configured
- without a published database it opens database.dsn and publishes it, and
  without a published bucket it opens storage.uploads.bucket_url, closing
  what it opened
This commit is contained in:
Jakub Zych
2026-11-04 19:27:00 +01:00
parent 4f5bd190e5
commit fc3c25530c
4 changed files with 168 additions and 10 deletions

View File

@@ -211,7 +211,7 @@ 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.
- **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.
- **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).