docs(lagoon): attach/webp also decodes WebP
Importing attach/webp registers the encoder library's WebP decoder ahead of the pure Go one for the whole process, so WebP uploads are decoded through the system libwebp when it is installed. The lagoon README and the attachments page say so and name -tags nodynamic.
This commit is contained in:
@@ -127,6 +127,8 @@ A variant that exists is returned without writing, so a job can run again safely
|
||||
|
||||
The encoder is `github.com/gen2brain/webp`. It loads the system libwebp (`libwebp.so`, `libwebpdemux.so`) through purego when the library is installed, without cgo, and otherwise falls back to libwebp transpiled to Go, about five times slower. Only binaries that import `attach/webp` link it. Such a binary is dynamically linked against glibc, even with `CGO_ENABLED=0`, so it runs on Debian or Ubuntu hosts but not in a `scratch` or musl image. Build it with `-tags nodynamic` for a static binary that always uses the transpiled encoder.
|
||||
|
||||
Importing `attach/webp` also takes over WebP decoding for the whole process: the encoder library registers its own WebP decoder ahead of the pure Go one, so every WebP decode, user uploads included (thumbnails, the size check before thumbnailing), goes through the system libwebp when it is installed. Keep libwebp patched on such hosts, or build with `-tags nodynamic`, which also decodes with the transpiled copy.
|
||||
|
||||
## Storing an upload
|
||||
|
||||
`attach.Store` turns an upload into a `system_files` row. It takes an `attach.Upload` (the client's file name, the body and the public flag) and an `attach.Limits`, writes the bytes under the WinterCMS partition key and inserts an unattached row whose `sort_order` equals its id, as WinterCMS's Sortable trait does. The caller attaches the row later by setting `Field`, `AttachmentType` and `AttachmentID`, usually when the record's form is saved. When the row insert fails, the blob is deleted again.
|
||||
|
||||
Reference in New Issue
Block a user