aboutsummaryrefslogtreecommitdiff
path: root/layouts/shortcodes/img.html
blob: 9e50ce422ea8c30d364d23c4fa01cfe746264cfe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

{{ $img := .Page.Resources.GetMatch (printf "%s" (.Get "src" | safeURL )) }}
{{ $alt := .Get "alt" }}
{{ $caption := .Get "caption" }}
{{ $captionPosition := .Get "caption-position" }}

<figure class='mb-5'>
  <img src="{{ $img.RelPermalink }}" {{ with $alt }} alt="{{ . }}" {{ end }} width="{{ $img.Width }}" height="{{ $img.Height }}" loading="lazy" />
  
  {{ with $caption }}
    <figcaption 
      class='{{ if eq $captionPosition "center" }} flex justify-center {{ else if eq $captionPosition "end" }} flex justify-end {{ end }}'
    >
      {{ . }}
    </figcaption>
  {{ end }}
</figure>