33 lines
1.8 KiB
HTML
Raw Normal View History

2022-12-20 22:28:31 +01:00
<link rel="stylesheet" href={{ "css/hugo-easy-gallery.css" | relURL }} />
2020-07-30 17:37:15 +02:00
{{ $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">
2022-10-15 16:36:24 +02:00
{{- with (.Get "dir") -}}
{{- $files := readDir (print "/static/" .) }}
{{- range $files -}}
{{- $thumbext := $.Get "thumb" | default "-thumb" }}
{{- $isthumb := .Name | findRE ($thumbext | printf "%s\\.") }}
{{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp|webp|avif|jxl)" }}
2022-10-15 16:36:24 +02:00
{{- if and $isimg (not $isthumb) }}
{{- $caption := .Name | replaceRE "\\..*" "" | humanize }}
{{- $linkURL := print $baseURL "/" ($.Get "dir") "/" .Name | absURL }}
{{- $thumb := .Name | replaceRE "(\\.)" ($thumbext | printf "%s.") }}
{{- $thumbexists := where $files "Name" $thumb }}
{{- $thumbURL := print $baseURL ($.Get "dir") "/" $thumb | absURL }}
2020-07-30 17:37:15 +02:00
<div class="box">
2022-10-15 16:36:24 +02:00
<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>
<figcaption>
<p>{{ $caption }}</p>
</figcaption>
<a href="{{ $linkURL }}" itemprop="contentUrl"></a>
2022-10-15 16:36:24 +02:00
</figure>
2020-07-30 17:37:15 +02:00
</div>
{{- end }}
{{- end }}
2022-10-15 16:36:24 +02:00
{{- else -}}
{{ .Inner }}
2020-07-30 17:37:15 +02:00
{{- end }}
2022-10-15 16:36:24 +02:00
</div>