Add download links to thumbnails in photo viewer

This commit is contained in:
Michael Mayer
2019-05-16 04:03:55 +02:00
parent b73093c2f0
commit 0400b6ec7a
7 changed files with 74 additions and 13 deletions

View File

@@ -50,6 +50,12 @@ func GetThumbnail(router *gin.RouterGroup, conf *config.Config) {
}
if thumbnail, err := photoprism.ThumbnailFromFile(fileName, file.FileHash, conf.ThumbnailsPath(), thumbType.Width, thumbType.Height, thumbType.Options...); err == nil {
if c.Query("download") != "" {
downloadFileName := file.DownloadFileName()
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", downloadFileName))
}
c.File(thumbnail)
} else {
log.Errorf("could not create thumbnail: %s", err)