aboutsummaryrefslogtreecommitdiff
path: root/layouts/shortcodes/img.html
blob: a0673a37c5a8bb4b6e303386c168656c4ee9a793 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

{{/*  Image Resources  */}}
{{ $img := .Page.Resources.GetMatch (printf "%s" (.Get "src" | safeURL ))}}
{{ $alt := .Get "alt"}}

{{/*  Image Processing  */}}
{{ $command := .Get "size-method" }}
{{ $options := .Get "size-format" }}
{{ if eq $command "Fit"}}
  {{ $img = $img.Fit $options }}
{{ else if eq $command "Resize"}}
  {{ $img = $img.Resize $options }}
{{ else if eq $command "Fill"}}
  {{ $img = $img.Fill $options }}
{{ else if eq $command "Crop"}}
  {{ $img = $img.Crop $options }}
{{ end }}

{{/*  Position  */}}
{{ $position := .Get "position" }}

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