feat: image variants job and variants in the post API
- golem15_journal_image_variants (migration 202610280002): a thumbnail
per width of golem15.journal.image_widths (480, 800, 1200 by default,
never wider than the original) and its WebP copy, with the original's
size
- conga job golem15.journal.image_variants (three attempts), queued after
a featured image upload and after an admin save of a post whose images
lack a width; the upload request never encodes
- journal:image-variants [--all] backfills
- featured_images[].variants {width, height, url, webp_url, source_width,
source_height} on the post answers (additive key)
This commit is contained in:
27
models/image_variant.go
Normal file
27
models/image_variant.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// ImageVariant is one size of a featured image on
|
||||
// golem15_journal_image_variants (P33-43): the thumbnail of the original at
|
||||
// Width by Height (Key, in the original's format) and its WebP copy
|
||||
// (WebPKey), both blob keys of the uploads bucket. SourceWidth and
|
||||
// SourceHeight are the original's size. One row per file and width, so the
|
||||
// API lists a post's variants with one query instead of storage lookups.
|
||||
type ImageVariant struct {
|
||||
ID uint `gorm:"column:id;primaryKey"`
|
||||
FileID uint `gorm:"column:file_id"`
|
||||
Width int `gorm:"column:width"`
|
||||
Height int `gorm:"column:height"`
|
||||
Key string `gorm:"column:key"`
|
||||
WebPKey string `gorm:"column:webp_key"`
|
||||
SourceWidth int `gorm:"column:source_width"`
|
||||
SourceHeight int `gorm:"column:source_height"`
|
||||
CreatedAt time.Time `gorm:"column:created_at"`
|
||||
}
|
||||
|
||||
func (ImageVariant) TableName() string { return "golem15_journal_image_variants" }
|
||||
|
||||
func init() {
|
||||
Register(ImageVariant{})
|
||||
}
|
||||
Reference in New Issue
Block a user