1
Fork 0

Use high quality images in gallery, and make only 1 API call

This commit is contained in:
Jake Howard 2018-12-01 21:19:13 +00:00
parent 1128182535
commit 9a5b16934d
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -6,24 +6,20 @@
{{ $id := .Params.photoset }}
{{ $query := querify "format" "json" "nojsoncallback" "1" "api_key" .Site.Data.flickr.api_key }}
{{ $method := querify "method" "flickr.photosets.getPhotos" "user_id" .Site.Data.flickr.user_id "photoset_id" $id "extras" "url_l" }}
{{ $photoset_orig:= (getJSON "https://api.flickr.com/services/rest/?" $query "&" $method).photoset }}
{{ $method := querify "method" "flickr.photosets.getPhotos" "user_id" .Site.Data.flickr.user_id "photoset_id" $id "extras" "url_sq" }}
{{ $photoset_thumb := (getJSON "https://api.flickr.com/services/rest/?" $query "&" $method).photoset }}
{{ $method := querify "method" "flickr.photosets.getPhotos" "user_id" .Site.Data.flickr.user_id "photoset_id" $id "extras" "url_k,url_q" }}
{{ $photoset := (getJSON "https://api.flickr.com/services/rest/?" $query "&" $method).photoset }}
<div id="light-gallery" class="row">
{{ range $index, $element := $photoset_orig.photo }}
{{ $thumb := (index $photoset_thumb.photo $index).url_sq }}
<a href="{{ $element.url_l }}" title="{{ $element.title }}" class="col-2">
<img src="{{ $thumb }}" alt="{{ $element.title }}"/>
{{ range $element := $photoset.photo }}
<a href="{{ $element.url_k }}" title="{{ $element.title }}" class="col-md-2 col-xs-12">
<img src="{{ $element.url_q }}" alt="{{ $element.title }}"/>
</a>
{{ end }}
</div>
<h4>
<a href="{{ .Site.Data.social.accounts.flickr.link }}sets/{{ $id }}/">
View entire <i>{{ $photoset_orig.title }}</i> album on Flickr
View entire <i>{{ $photoset.title }}</i> album on Flickr
</a>
</h4>
</div>