summaryrefslogtreecommitdiff
path: root/layouts/shortcodes/img-center.html
blob: 71214148907480bbf8aa1824f9be7054928abe07 (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
{{- $file := .Get 0 }}
{{- $path := printf "content_images/%s" $file}}
{{- $img := resources.Get $path }}
{{- $caption := .Get 1 }}
{{- $source := .Get 2 }}
{{- $img1x := $img.Resize "450x webp q90"}}
{{- $img2x := $img.Resize "900x webp q90"}}
<center>
<figure>
  <img 
    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>
</center>