31 lines
1.1 KiB
HTML
31 lines
1.1 KiB
HTML
{{ $original := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }}
|
|
{{ $command := strings.ToLower (printf "%s" (.Get 1)) }}
|
|
{{ $options := .Get 2 }}
|
|
{{ $customAlt := .Get 3 }}
|
|
{{ if eq $command "fit"}}
|
|
{{ .Scratch.Set "image" ($original.Fit $options) }}
|
|
{{ else if eq $command "resize"}}
|
|
{{ .Scratch.Set "image" ($original.Resize $options) }}
|
|
{{ else if eq $command "fill"}}
|
|
{{ .Scratch.Set "image" ($original.Fill $options) }}
|
|
{{ else }}
|
|
{{ errorf "Invalid image processing command: Must be one of Fit, Fill or Resize. Is: %s" ($command)}}
|
|
{{ end }}
|
|
{{ $image := .Scratch.Get "image" }}
|
|
{{ $imgAlt := $original.Title }}
|
|
{{ if $customAlt }}
|
|
{{ $imgAlt = $customAlt }}
|
|
{{ end }}
|
|
<figure class="post-figure">
|
|
<a href="{{ $original.RelPermalink }}">
|
|
<img class="post-figure__img" src="{{ $image.RelPermalink }}" alt="{{ $imgAlt }}" width="{{ $image.Width }}" height="{{ $image.Height }}">
|
|
</a>
|
|
<figcaption class="post-figure__caption">
|
|
<small>
|
|
{{ with not .Inner }}
|
|
{{ $original.Title }}
|
|
{{ end }}
|
|
</small>
|
|
</figcaption>
|
|
</figure>
|