1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-11 02:13:41 +09:00

fix unsplash

This commit is contained in:
Roman Khafizianov 2022-03-11 00:19:56 +01:00
parent 2916d9d55f
commit 0aedfb953d
No known key found for this signature in database
GPG key ID: F07A7D55A2684852

View file

@ -15,6 +15,7 @@ import (
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
"path/filepath"
"regexp"
@ -101,11 +102,17 @@ func newFromPhoto(v unsplash.Photo) (Result, error) {
res.PictureSmallUrl = v.Urls.Small.String()
}
if v.Urls.Regular != nil {
fUrl := v.Urls.Small.String()
fUrl := v.Urls.Regular.String()
// hack to have full hd instead of 1080w,
// in case unsplash will change the URL format it will not break things
fUrl = strings.Replace(fUrl, "&w=1080", "&w=1920", 1)
res.PictureHDUrl = fUrl
u, _ := url.Parse(fUrl)
if u != nil {
if q := u.Query(); q.Get("w") != "" {
q.Set("w", "1920")
u.RawQuery = q.Encode()
}
}
res.PictureHDUrl = u.String()
}
if v.Urls.Full != nil {
res.PictureFullUrl = v.Urls.Full.String()