From 6df865876df961f2bec476126bf6e7fbe5d43e0e Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 12 Dec 2021 21:49:42 +0100 Subject: [PATCH] feat: return BlurHash for unsplash search results --- pkg/modules/background/background.go | 7 ++++--- pkg/modules/background/unsplash/unsplash.go | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/modules/background/background.go b/pkg/modules/background/background.go index 057a446c..bd6cc2ab 100644 --- a/pkg/modules/background/background.go +++ b/pkg/modules/background/background.go @@ -24,9 +24,10 @@ import ( // Image represents an image which can be used as a list background type Image struct { - ID string `json:"id"` - URL string `json:"url"` - Thumb string `json:"thumb,omitempty"` + ID string `json:"id"` + URL string `json:"url"` + Thumb string `json:"thumb,omitempty"` + BlurHash string `json:"blur_hash"` // This can be used to supply extra information from an image provider to clients Info interface{} `json:"info,omitempty"` } diff --git a/pkg/modules/background/unsplash/unsplash.go b/pkg/modules/background/unsplash/unsplash.go index 60fd14ec..02d0e47b 100644 --- a/pkg/modules/background/unsplash/unsplash.go +++ b/pkg/modules/background/unsplash/unsplash.go @@ -179,8 +179,9 @@ func (p *Provider) Search(s *xorm.Session, search string, page int64) (result [] result = []*background.Image{} for _, p := range collectionResult { result = append(result, &background.Image{ - ID: p.ID, - URL: getImageID(p.Urls.Raw), + ID: p.ID, + URL: getImageID(p.Urls.Raw), + BlurHash: p.BlurHash, Info: &models.UnsplashPhoto{ UnsplashID: p.ID, Author: p.User.Username,