- 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)
28 lines
1.0 KiB
Go
28 lines
1.0 KiB
Go
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{})
|
|
}
|