pages/layouts/shortcodes/imgproc.html

32 lines
887 B
HTML
Raw Normal View History

2022-06-29 02:46:02 +00:00
{{ $img := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }}
{{ $command := .Get 1 }}
{{ $options := .Get 2 }}
{{ $figclass := .Get 3 }}
{{ $imgclass := .Get 4 }}
2023-02-25 05:13:45 +00:00
{{ if eq $command "Fit" }}
2022-06-29 02:46:02 +00:00
{{ $img = $img.Fit $options }}
2023-02-25 05:13:45 +00:00
{{ else if eq $command "Resize" }}
2022-06-29 02:46:02 +00:00
{{ $img = $img.Resize $options }}
2023-02-25 05:13:45 +00:00
{{ else if eq $command "Fill" }}
2022-06-29 02:46:02 +00:00
{{ $img = $img.Fill $options }}
2023-02-25 05:13:45 +00:00
{{ else if eq $command "Crop" }}
2022-06-29 02:46:02 +00:00
{{ $img = $img.Crop $options }}
{{ else }}
2023-02-25 05:13:45 +00:00
{{ errorf "Invalid image processing command: Must be one of Crop, Fit, Fill or Resize." }}
2022-06-29 02:46:02 +00:00
{{ end }}
<figure class="figure {{ $figclass }}">
2023-02-25 05:13:45 +00:00
<img
class="figure-img img img-fluid"
src="{{ $img.RelPermalink }}"
width="{{ $img.Width }}"
height="{{ $img.Height }}"
/>
{{ with .Inner }}
<figcaption class="figure-caption">
<small>
{{ . | markdownify }}
</small>
</figcaption>
{{ end }}
2022-06-29 02:46:02 +00:00
</figure>