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>
This commit is contained in:
36
app/internal/gallery/media.go
Normal file
36
app/internal/gallery/media.go
Normal file
@@ -0,0 +1,36 @@
|
||||
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 {
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user