@ -0,0 +1,59 @@ |
|||||||
|
package controllers |
||||||
|
|
||||||
|
import ( |
||||||
|
"net/http" |
||||||
|
"path/filepath" |
||||||
|
|
||||||
|
"github.com/owncast/owncast/config" |
||||||
|
"github.com/owncast/owncast/utils" |
||||||
|
) |
||||||
|
|
||||||
|
// GetThumbnail will return the thumbnail image as a response.
|
||||||
|
func GetThumbnail(w http.ResponseWriter, r *http.Request) { |
||||||
|
imageFilename := "thumbnail.jpg" |
||||||
|
imagePath := filepath.Join(config.TempDir, imageFilename) |
||||||
|
|
||||||
|
var imageBytes []byte |
||||||
|
var err error |
||||||
|
|
||||||
|
if utils.DoesFileExists(imagePath) { |
||||||
|
imageBytes, err = getImage(imagePath) |
||||||
|
} else { |
||||||
|
GetLogo(w, r) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
if err != nil { |
||||||
|
GetLogo(w, r) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
contentType := "image/jpeg" |
||||||
|
cacheTime := utils.GetCacheDurationSecondsForPath(imagePath) |
||||||
|
writeBytesAsImage(imageBytes, contentType, w, cacheTime) |
||||||
|
} |
||||||
|
|
||||||
|
// GetPreview will return the preview gif as a response.
|
||||||
|
func GetPreview(w http.ResponseWriter, r *http.Request) { |
||||||
|
imageFilename := "preview.gif" |
||||||
|
imagePath := filepath.Join(config.TempDir, imageFilename) |
||||||
|
|
||||||
|
var imageBytes []byte |
||||||
|
var err error |
||||||
|
|
||||||
|
if utils.DoesFileExists(imagePath) { |
||||||
|
imageBytes, err = getImage(imagePath) |
||||||
|
} else { |
||||||
|
GetLogo(w, r) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
if err != nil { |
||||||
|
GetLogo(w, r) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
contentType := "image/jpeg" |
||||||
|
cacheTime := utils.GetCacheDurationSecondsForPath(imagePath) |
||||||
|
writeBytesAsImage(imageBytes, contentType, w, cacheTime) |
||||||
|
} |
||||||
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 8.0 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 9.4 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 6.6 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
After Width: | Height: | Size: 374 B |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 483 B |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 376 B |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 8.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 126 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 7.4 KiB |