Files
caldwell/layouts/partials/image.html
Nikolaos Karaolidis 9d160b6890 Add photoswipe
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2025-08-08 19:44:04 +02:00

30 lines
847 B
HTML

{{- $path := .path -}}
{{- $caption := .caption -}}
{{- $alt := default .caption .alt -}}
{{- if $path -}}
{{- $isRemote := strings.HasPrefix $path "http" -}}
{{- $image := cond $isRemote (resources.GetRemote $path) (resources.Get $path) -}}
{{- if $image -}}
<figure class="image gallery">
<a
href="{{- $image.RelPermalink -}}"
data-pswp-width="{{- $image.Width -}}"
data-pswp-height="{{- $image.Height -}}"
>
<img
src="{{- $image.RelPermalink -}}"
width="{{- $image.Width -}}"
height="{{- $image.Height -}}"
{{ with $caption }}title="{{- . -}}"{{ end }}
{{ with $alt }}alt="{{- . -}}"{{ end }}
/>
</a>
{{ with $caption }}
<figcaption>{{ . }}</figcaption>
{{ end }}
</figure>
{{- end -}}
{{- end -}}