hugo-theme-hello-friend/layouts/shortcodes/imgproc.html

26 lines
878 B
HTML
Raw Normal View History

2019-08-03 18:25:32 +02:00
{{ $original := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }}
{{ $command := .Get 1 }}
{{ $options := .Get 2 }}
2020-01-29 06:45:05 +01:00
{{ $position := .Get 3}}
2019-08-03 18:25:32 +02:00
{{ 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."}}
{{ end }}
{{ $image := .Scratch.Get "image" }}
2020-01-29 06:45:05 +01:00
<figure class="{{ with $position }}{{ . }}{{ else -}} left {{- end }}" >
2019-08-03 18:25:32 +02:00
<img style="max-width: 100%; width: auto; height: auto; border-radius: 8px;" src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}">
{{ with .Inner }}
<figcaption>
{{ . }}
</figcaption>
{{ end }}
</figure>