Files
website/app/internal/gallery/hero.go
jimmy 45b31be9a7 Add gallery admin and video media support.
This updates gallery handling to support video playback with generated poster thumbnails, adds authenticated admin upload/delete flows, and improves dev/runtime behavior including reliable thumbnail generation and media-safe response handling.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-02 23:01:02 +12:00

40 lines
770 B
Go

package gallery
import (
"os"
"strings"
)
const defaultHeroRel = "connectionmachine/20220723_231556.jpg"
// HeroRelPath returns the configured hero image path relative to images/.
func HeroRelPath() string {
if p := strings.TrimSpace(os.Getenv("HERO_IMAGE")); p != "" {
return filepathToSlash(p)
}
return defaultHeroRel
}
// SelectHero picks the homepage hero from the gallery list.
func SelectHero(images []Image) (Image, bool) {
want := HeroRelPath()
for _, img := range images {
if img.IsVideo {
continue
}
if img.RelPath == want {
return img, true
}
}
for _, img := range images {
if !img.IsVideo {
return img, true
}
}
return Image{}, false
}
func filepathToSlash(p string) string {
return strings.ReplaceAll(p, "\\", "/")
}