2019-10-21 08:22:28 +00:00
|
|
|
{{ $original := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }}
|
|
|
|
{{ $command := .Get 1 }}
|
|
|
|
{{ $options := .Get 2 }}
|
|
|
|
{{ 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) }}
|
2022-03-08 18:37:17 +00:00
|
|
|
{{ else if eq $command "Crop"}}
|
|
|
|
{{ .Scratch.Set "image" ($original.Crop $options) }}
|
2019-10-21 08:22:28 +00:00
|
|
|
{{ else }}
|
2022-03-08 18:37:17 +00:00
|
|
|
{{ errorf "Invalid image processing command: Must be one of Crop, Fit, Fill or Resize."}}
|
2019-10-21 08:22:28 +00:00
|
|
|
{{ end }}
|
|
|
|
{{ $image := .Scratch.Get "image" }}
|
|
|
|
<figure style="padding: 0.25rem; margin: 2rem 0; background-color: #cccc">
|
|
|
|
<img style="max-width: 100%; width: auto; height: auto;" src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}">
|
|
|
|
<figcaption>
|
|
|
|
<small>
|
|
|
|
{{ with .Inner }}
|
|
|
|
{{ . }}
|
|
|
|
{{ else }}
|
|
|
|
.{{ $command }} "{{ $options }}"
|
|
|
|
{{ end }}
|
|
|
|
</small>
|
|
|
|
</figcaption>
|
|
|
|
</figure>
|