Fix thumbnail loading and startup gallery refresh.
Refresh gallery metadata after thumbnail generation so new thumb URLs are available immediately, and lazy-load gallery thumbnails with IntersectionObserver to avoid fetching all images on initial page load. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -70,6 +70,17 @@ func New(imagesDir, staticDir string, mailCfg *mail.Config) (*Server, error) {
|
||||
} else {
|
||||
log.Print("gallery thumbnails: ready")
|
||||
}
|
||||
// Thumbnail URLs are resolved during gallery.List. Re-list after derivative
|
||||
// generation so newly-created thumbs appear immediately on first load.
|
||||
if refreshed, err := gallery.List(imagesDir); err != nil {
|
||||
log.Printf("gallery refresh after thumbnails: %v", err)
|
||||
} else {
|
||||
srv.Images = refreshed
|
||||
if hero, hasHero := gallery.SelectHero(refreshed); hasHero {
|
||||
srv.Hero = hero
|
||||
srv.HasHero = true
|
||||
}
|
||||
}
|
||||
return srv, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user