diff --git a/static/nothumb_1024.png b/static/nothumb_1024.png new file mode 100644 index 0000000..c84a018 Binary files /dev/null and b/static/nothumb_1024.png differ diff --git a/static/nothumb_160.png b/static/nothumb_160.png new file mode 100644 index 0000000..7f6437b Binary files /dev/null and b/static/nothumb_160.png differ diff --git a/static/nothumb_340.png b/static/nothumb_340.png new file mode 100644 index 0000000..955dbb0 Binary files /dev/null and b/static/nothumb_340.png differ diff --git a/static/nothumb_640.png b/static/nothumb_640.png new file mode 100644 index 0000000..4c6210c Binary files /dev/null and b/static/nothumb_640.png differ diff --git a/static/nothumb_90.png b/static/nothumb_90.png new file mode 100644 index 0000000..66f92d7 Binary files /dev/null and b/static/nothumb_90.png differ diff --git a/thumb.go b/thumb.go index 4c16451..6b52119 100644 --- a/thumb.go +++ b/thumb.go @@ -39,18 +39,23 @@ func thumbnailer(t byte) (*thumbnail.Thumbnailer, error) { } func (this *Server) handleThumb(w http.ResponseWriter, r *http.Request, thumbnailType byte, fileId string) { - err := this.handleThumbInternal(w, thumbnailType, fileId) + t, err := thumbnailer(thumbnailType) if err != nil { log.Printf("%s Thumbnail failed: %s\n", this.remoteIP(r), err.Error()) - http.Error(w, "Couldn't provide content", 500) + http.Error(w, err.Error(), 400) + return + } + + err = this.handleThumbInternal(w, t, fileId) + if err != nil { + log.Printf("%s Thumbnail failed: %s\n", this.remoteIP(r), err.Error()) + + w.Header().Set(`Location`, fmt.Sprintf(`/nothumb_%d.png`, t.Height())) + w.WriteHeader(302) } } -func (this *Server) handleThumbInternal(w http.ResponseWriter, thumbnailType byte, fileId string) error { - t, err := thumbnailer(thumbnailType) - if err != nil { - return err - } +func (this *Server) handleThumbInternal(w http.ResponseWriter, t *thumbnail.Thumbnailer, fileId string) error { // Load metadata m, err := this.Metadata(fileId)