mirror of
https://github.com/vbatts/imgsrv.git
synced 2025-06-30 14:38:28 +00:00
ZOMG, just ironed out the '/v/' page, to handle embedding video with
html5 tag
This commit is contained in:
parent
967daf48b2
commit
c62df15429
3 changed files with 47 additions and 11 deletions
|
@ -5,7 +5,6 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Info struct {
|
||||
|
@ -22,12 +21,19 @@ type File struct {
|
|||
UploadDate time.Time
|
||||
Length int64
|
||||
Filename string ",omitempty"
|
||||
IsImage bool
|
||||
ContentType string "contentType,omitempty"
|
||||
}
|
||||
|
||||
func (f *File) SetIsImage() {
|
||||
m_type := mime.TypeByExtension(filepath.Ext(f.Filename))
|
||||
f.IsImage = strings.Contains(m_type, "image")
|
||||
fmt.Println(f.Filename,f.IsImage)
|
||||
func (f *File) SetContentType() {
|
||||
f.ContentType = mime.TypeByExtension(filepath.Ext(f.Filename))
|
||||
}
|
||||
|
||||
func (f *File) IsImage() bool {
|
||||
f.SetContentType()
|
||||
return strings.HasPrefix(f.ContentType, "image")
|
||||
}
|
||||
|
||||
func (f *File) IsVideo() bool {
|
||||
f.SetContentType()
|
||||
return strings.HasPrefix(f.ContentType, "video")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue