diff --git a/pkg/controller/account/settings.go b/pkg/controller/account/settings.go index a39f647..45daf16 100644 --- a/pkg/controller/account/settings.go +++ b/pkg/controller/account/settings.go @@ -124,12 +124,17 @@ func Settings() http.HandlerFunc { var ( explicit = r.PostFormValue("explicit") == "true" blurExplicit = r.PostFormValue("blur_explicit") + autoplayGif = r.PostFormValue("autoplay_gif") ) user.Explicit = explicit // Set profile field prefs. user.SetProfileField("blur_explicit", blurExplicit) + if autoplayGif != "true" { + autoplayGif = "false" + } + user.SetProfileField("autoplay_gif", autoplayGif) if err := user.Save(); err != nil { session.FlashError(w, r, "Failed to save user to database: %s", err) diff --git a/web/static/js/bulma.js b/web/static/js/bulma.js index 4f13841..36d6a46 100644 --- a/web/static/js/bulma.js +++ b/web/static/js/bulma.js @@ -137,5 +137,13 @@ document.addEventListener('DOMContentLoaded', () => { e.stopPropagation(); } }); + + // Video tag: autoplay is disabled when blurred, onClick doesn't fire, + // set the handler for onPlay. + node.addEventListener("play", e => { + if (node.classList.contains("blurred-explicit")) { + node.classList.remove("blurred-explicit"); + } + }); }); }); diff --git a/web/templates/account/dashboard.html b/web/templates/account/dashboard.html index b956dd1..506c0d9 100644 --- a/web/templates/account/dashboard.html +++ b/web/templates/account/dashboard.html @@ -491,10 +491,13 @@ {{if $Body.PhotoID}} -
+
{{if HasSuffix $Body.Photo.Filename ".mp4"}} -
+
+ + +

+ Uncheck this box to disable auto-play on GIFs. +

+
+
- - - {{if .Forum.PermitPhotos}} - - {{end}} - {{end}} {{define "scripts"}} + + +{{if .Forum.PermitPhotos}} + +{{end}} + -{{end}} \ No newline at end of file +{{end}} diff --git a/web/templates/photo/gallery.html b/web/templates/photo/gallery.html index 3c09f68..3645a4d 100644 --- a/web/templates/photo/gallery.html +++ b/web/templates/photo/gallery.html @@ -403,7 +403,10 @@
{{if HasSuffix .Filename ".mp4"}} -