thumbnailer: display a static error image on failure
This commit is contained in:
parent
a6e495f74d
commit
23ad509f33
BIN
static/nothumb_1024.png
Normal file
BIN
static/nothumb_1024.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.4 KiB |
BIN
static/nothumb_160.png
Normal file
BIN
static/nothumb_160.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
static/nothumb_340.png
Normal file
BIN
static/nothumb_340.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
static/nothumb_640.png
Normal file
BIN
static/nothumb_640.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
BIN
static/nothumb_90.png
Normal file
BIN
static/nothumb_90.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
19
thumb.go
19
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)
|
||||
|
Loading…
Reference in New Issue
Block a user