Sample gallery
This commit is contained in:
parent
29d6917b29
commit
c407648364
6 changed files with 35 additions and 0 deletions
7
site/content/post/gallery1.md
Normal file
7
site/content/post/gallery1.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
date: 2019-02-13 20:00:00
|
||||
tags: ["photos"]
|
||||
title: "Galerie d'exemple"
|
||||
---
|
||||
|
||||
{{< gallery dir="/images/gallery1" >}}
|
28
site/layouts/shortcodes/gallery.html
Normal file
28
site/layouts/shortcodes/gallery.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
{{ $baseURL := .Site.BaseURL }}
|
||||
<div class="gallery caption-position-{{ with .Get "caption-position" | default "bottom" }}{{.}}{{end}} caption-effect-{{ with .Get "caption-effect" | default "slide" }}{{.}}{{end}} hover-effect-{{ with .Get "hover-effect" | default "zoom" }}{{.}}{{end}} {{ if ne (.Get "hover-transition") "none" }}hover-transition{{end}}" itemscope itemtype="http://schema.org/ImageGallery">
|
||||
{{- with (.Get "dir") -}}
|
||||
<!-- If a directory was specified, generate figures for all of the images in the directory -->
|
||||
{{- $files := readDir (print "/static/" .) }}
|
||||
{{- range $files -}}
|
||||
<!-- skip files that aren't images, or that inlcude the thumb suffix in their name -->
|
||||
{{- $thumbext := $.Get "thumb" | default "-thumb" }}
|
||||
{{- $isthumb := .Name | findRE ($thumbext | printf "%s\\.") }}<!-- is the current file a thumbnail image? -->
|
||||
{{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp)" }}<!-- is the current file an image? -->
|
||||
{{- if and $isimg (not $isthumb) }}
|
||||
{{- $caption := .Name | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension -->
|
||||
{{- $linkURL := print $baseURL ($.Get "dir") "/" .Name | absURL }}<!-- absolute URL to hi-res image -->
|
||||
{{- $thumb := .Name | replaceRE "(\\.)" ($thumbext | printf "%s.") }}<!-- filename of thumbnail image -->
|
||||
{{- $thumbexists := where $files "Name" $thumb }}<!-- does a thumbnail image exist? -->
|
||||
{{- $thumbURL := print $baseURL ($.Get "dir") "/" $thumb | absURL }}<!-- absolute URL to thumbnail image -->
|
||||
<div class="box">
|
||||
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
|
||||
<div class="img" style="background-image: url('{{ if $thumbexists }}{{ $thumbURL }}{{ else }}{{ $linkURL }}{{ end }}');" >
|
||||
<img itemprop="thumbnail" src="{{ if $thumbexists }}{{ $thumbURL }}{{ else }}{{ $linkURL }}{{ end }}" alt="{{ $caption }}" /><!-- <img> hidden if in .gallery -->
|
||||
</div>
|
||||
<a href="{{ $linkURL }}" itemprop="contentUrl"></a><!-- put <a> last so it is stacked on top -->
|
||||
</figure>
|
||||
</div>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</div>
|
BIN
site/static/images/gallery1/banner.jpg
Normal file
BIN
site/static/images/gallery1/banner.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
BIN
site/static/images/gallery1/banner2.jpg
Normal file
BIN
site/static/images/gallery1/banner2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 192 KiB |
BIN
site/static/images/gallery1/banner3.jpg
Normal file
BIN
site/static/images/gallery1/banner3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
BIN
site/static/images/gallery1/banner4.jpg
Normal file
BIN
site/static/images/gallery1/banner4.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 76 KiB |
Loading…
Add table
Reference in a new issue