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:
parent
2916d9d55f
commit
0aedfb953d
1 changed files with 10 additions and 3 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue