Stage raw files in upload/, publish with make sync-media/publish, and polish the lightbox: autoplay, remembered volume, Escape to close, and image/video icons without poster or caption clutter. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
856 B
Go
44 lines
856 B
Go
package gallery
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
func isVideo(name string) bool {
|
|
switch strings.ToLower(filepath.Ext(name)) {
|
|
case ".mp4", ".webm", ".mov":
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func isGalleryMedia(name string) bool {
|
|
if isWebDerivative(name) {
|
|
return false
|
|
}
|
|
return isJPEG(name) || isVideo(name)
|
|
}
|
|
|
|
// thumbLookupRel is the path under thumbs/ (and hero/) used to find derivatives.
|
|
// Videos use a JPEG poster: clip.mp4 → clip.jpg.
|
|
func thumbLookupRel(rel string) string {
|
|
if isVideo(filepath.Base(rel)) {
|
|
return videoPosterRel(rel)
|
|
}
|
|
return rel
|
|
}
|
|
|
|
func videoPosterRel(rel string) string {
|
|
ext := filepath.Ext(rel)
|
|
if ext == "" {
|
|
return rel + ".jpg"
|
|
}
|
|
return strings.TrimSuffix(rel, ext) + ".jpg"
|
|
}
|
|
|
|
func isWebDerivative(name string) bool {
|
|
return strings.HasSuffix(strings.ToLower(name), ".web.mp4")
|
|
}
|