Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Add an endpoint for returning a most-compatible logo (non-svg) used in sharing and indexing. Closes #1286

Gabe Kangasc822fa2e89f3
diff --git a/controllers/index.go b/controllers/index.go
index a8df377b67..b793c516bb 100644
--- a/controllers/index.go
+++ b/controllers/index.go
@@ -91,7 +91,7 @@ func handleScraperMetadataPage(w http.ResponseWriter, r *http.Request) {
if err != nil {
log.Panicln(err)
}
- imageURL, err := url.Parse(fmt.Sprintf("%s://%s%s", scheme, r.Host, "/logo"))
+ imageURL, err := url.Parse(fmt.Sprintf("%s://%s%s", scheme, r.Host, "/logo/external"))
if err != nil {
log.Panicln(err)
}
diff --git a/controllers/logo.go b/controllers/logo.go
index 4b3821a749..6db2cc465c 100644
--- a/controllers/logo.go
+++ b/controllers/logo.go
@@ -39,6 +39,39 @@ func GetLogo(w http.ResponseWriter, r *http.Request) {
writeBytesAsImage(imageBytes, contentType, w, cacheTime)
}
+// GetCompatibleLogo will return the logo unless it's a SVG
+// and in that case will return a default placeholder.
+// Used for sharing to external social networks that generally
+// don't support SVG.
+func GetCompatibleLogo(w http.ResponseWriter, r *http.Request) {
+ imageFilename := data.GetLogoPath()
+
+ // If the logo image is not a SVG then we can return it
+ // without any problems.
+ if imageFilename != "" && filepath.Ext(imageFilename) != ".svg" {
+ GetLogo(w, r)
+ return
+ }
+
+ // Otherwise use a fallback logo.png.
+ imagePath := filepath.Join(config.WebRoot, "img", "logo.png")
+ contentType := "image/png"
+ imageBytes, err := getImage(imagePath)
+ if err != nil {
+ returnDefault(w)
+ return
+ }
+
+ cacheTime := utils.GetCacheDurationSecondsForPath(imagePath)
+ writeBytesAsImage(imageBytes, contentType, w, cacheTime)
+
+ referrer := r.Referer()
+ if referrer == "" {
+ referrer = "an external site"
+ }
+ log.Warnf("%s requested your logo. because many social networks do not support SVGs we returned a placeholder instead. change your current logo \"%s\" to a png or jpeg to be most compatible with external social networking sites.", referrer, imageFilename)
+}
+
func returnDefault(w http.ResponseWriter) {
imagePath := filepath.Join(config.WebRoot, "img", "logo.svg")
imageBytes, err := getImage(imagePath)
diff --git a/router/router.go b/router/router.go
index ec9b07220f..bc05fa48ac 100644
--- a/router/router.go
+++ b/router/router.go
@@ -57,6 +57,9 @@ func Start() error {
// return the logo
http.HandleFunc("/logo", controllers.GetLogo)
+ // return a logo that's compatible with external social networks
+ http.HandleFunc("/logo/external", controllers.GetCompatibleLogo)
+
// return the list of video variants available
http.HandleFunc("/api/video/variants", controllers.GetVideoStreamOutputVariants)