hugo-snotra/layouts/shortcodes/img.html

32 lines
773 B
HTML
Raw Normal View History

2020-04-28 12:26:34 +02:00
{{ $img := $.Page.Resources.GetMatch (.Get "src")}}
<figure {{ with .Get "class" }} class="{{ . }}"{{ end }}>
{{ with .Get "link" }}
<a href="{{ . | absURL }}">
2020-04-28 12:26:34 +02:00
{{ end }}
<img src="{{ $img.RelPermalink }}"
{{ with .Get "alt"}} alt="{{ . }}"{{ end }}
{{ with .Get "title"}} title="{{ . }}"{{ end }}
{{ with .Get "height"}} height="{{ . }}"{{ end }}
{{ with .Get "width"}} width="{{ . }}"{{ end }} />
2020-04-28 12:26:34 +02:00
{{ with .Get "link" }}
</a>
{{ end }}
{{ if .Get "caption" }}
2020-04-28 12:26:34 +02:00
<figcaption>
<p>{{ .Get "caption" }}
{{ if .Get "attr" }}
<span class="attribution">
{{ with .Get "attrlink" }}
<a href="{{ . }}">
{{ end }}
{{ .Get "attr" }}
{{ with .Get "attrlink" }}
</a>
{{ end }}
</span>
{{ end }}
</p>
2020-04-28 12:26:34 +02:00
</figcaption>
{{ end }}
</figure>