Change thumbnail default size and resize algorithm (#336)

* Change thumbnail resize algorithm and add size parameter

* Height -> Width

* Change default size from 100px to 200px

* Height -> width
This commit is contained in:
InfiniteTF
2020-01-31 23:19:15 +01:00
committed by GitHub
parent 03c07a429d
commit 6a6e8d8875
10 changed files with 30 additions and 21 deletions

View File

@@ -27,9 +27,16 @@ func (rs galleryRoutes) File(w http.ResponseWriter, r *http.Request) {
thumb := r.URL.Query().Get("thumb")
w.Header().Add("Cache-Control", "max-age=604800000") // 1 Week
if thumb == "true" {
_, _ = w.Write(gallery.GetThumbnail(fileIndex))
} else {
_, _ = w.Write(gallery.GetThumbnail(fileIndex, 200))
} else if thumb == "" {
_, _ = w.Write(gallery.GetImage(fileIndex))
} else {
width, err := strconv.ParseInt(thumb, 0, 64)
if err != nil {
http.Error(w, http.StatusText(400), 400)
return
}
_, _ = w.Write(gallery.GetThumbnail(fileIndex, int(width)))
}
}