summaryrefslogtreecommitdiff
path: root/layouts/shortcodes/img-c.html
blob: 7411abb7f9e08c480954242a1d9be317311689fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{{- $file := .Get 0 }}
{{- $path := printf "content_images/%s" $file}}
{{- $img := resources.Get $path }}
{{- $caption := .Inner }}
{{- $source := .Get 1 }}
{{- $imgclass := .Get 2 }}
{{- $img1x := $img.Resize "800x webp q90"}}
{{- $img2x := $img.Resize "1600x webp q90"}}
<figure>
  <a href="{{ $img.Permalink }}">
    <img
      loading="lazy"
      class="center {{ $imgclass }}"
      alt="{{ $caption }}" 
      src="{{ $img1x.Permalink }}" 
      srcset="
              {{ $img1x.Permalink }} 1x,
              {{ $img2x.Permalink }} 2x
              "
      width="{{ $img1x.Width }}" 
      height="{{ $img1x.Height }}"
      >
  </a>
  <figcaption>
    {{ $caption }}

    {{- if $source }}
    <a href="{{ $source }}" target="_blank" title="source">[source]</a>
    {{ end }}
  </figcaption>
</figure>