summaryrefslogtreecommitdiff
path: root/layouts/shortcodes/img-c.html
blob: 3da2c5ce09e936a11a69a032a2cfbbf19ccd7477 (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
{{- $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>
  <img 
    class="center {{ $imgclass }}"
    alt="{{ $caption }}" 
    src="{{ $img1x.RelPermalink }}" 
    srcset="
            {{ $img1x.RelPermalink }} 1x,
            {{ $img2x.RelPermalink }} 2x
            "
    width="{{ $img1x.Width }}" 
    height="{{ $img1x.Height }}"
    >
  <figcaption>
    {{ $caption }}

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