diff --git a/preview.go b/preview.go index fd02226..61cee4f 100644 --- a/preview.go +++ b/preview.go @@ -16,10 +16,30 @@ func (this *Server) handlePreview(w http.ResponseWriter, fileIDList string) { fileIDs := strings.Split(fileIDList, `-`) + // Early get metadata for the first listed element + specialTitle := "" + if len(fileIDs) == 1 { + mFirst, err := this.Metadata(fileIDs[0]) + if err != nil { // Same error handling as below - + if os.IsNotExist(err) { + http.Error(w, "Not found", 404) + return + } + + log.Println(err.Error()) + http.Error(w, "Internal error", 500) + return + } + + specialTitle = mFirst.Filename + " (" + fileIDs[0] + ")" + } else { + specialTitle = fmt.Sprintf("%d images", len(fileIDs)) + } + tmpl := ` - ` + html.EscapeString(this.opts.ServerPublicProperties.AppTitle) + ` + ` + html.EscapeString(specialTitle+" | "+this.opts.ServerPublicProperties.AppTitle) + `