diff --git a/layouts/shortcodes/imgproc.html b/layouts/shortcodes/imgproc.html new file mode 100644 index 0000000..093124c --- /dev/null +++ b/layouts/shortcodes/imgproc.html @@ -0,0 +1,21 @@ +{{ $images := .Page.Resources.ByType "image" }} +{{ $original := $images.GetMatch (printf "%s*" (.Get 0)) }} +{{ $command := .Get 1 | default "Resize" }} +{{ $options := .Get 2 | default "smart" }} +{{ $caption := .Get 3 | default "" }} +{{ $options := print "1000x " $options}} +{{ 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 }} +{{ $original.ResourceType }} +{{ errorf "Invalid image processing command: Must be one of Fit, Fill or Resize."}} +{{ end }} +{{ $image := .Scratch.Get "image" }} +
+ +
{{ with .Inner }}{{ . }}{{ else }}{{ $caption }}{{ end }}
+
\ No newline at end of file