From 27f7bfc1f4d054ab2b4a0089c4d1b426f2975203 Mon Sep 17 00:00:00 2001 From: amazingrise <8315221+AmazingRise@users.noreply.github.com> Date: Wed, 29 Jul 2020 14:58:42 +0800 Subject: Add insertFigure shortcode. --- layouts/shortcodes/insertFigure.html | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 layouts/shortcodes/insertFigure.html (limited to 'layouts') diff --git a/layouts/shortcodes/insertFigure.html b/layouts/shortcodes/insertFigure.html new file mode 100644 index 0000000..e220646 --- /dev/null +++ b/layouts/shortcodes/insertFigure.html @@ -0,0 +1,34 @@ + +{{ $img := .Get "img" }} +{{ $caption := .Get "caption" }} +{{ $command := .Get "command" }} +{{ $options := .Get "options" }} +{{ $align := .Get "align" }} + +{{ $original := .Page.Resources.GetMatch (printf "*%s*" $img) }} +{{ $new := "" }} + +{{ if eq $command "Fit" }} + {{ $new = $original.Fit $options }} +{{ else if eq $command "Fill" }} + {{ $new = $original.Fill $options }} +{{ else if eq $command "Resize" }} + {{ $new = $original.Resize $options }} +{{ else if eq $command "Original" }} + {{ $new = $original }} +{{ else }} + {{ errorf "Invalid image processing command: Must be one of Fit, Fill, Resize, Original." }} +{{ end }} + +
+ + + +
+ {{ $caption | markdownify }} +
+
\ No newline at end of file -- cgit v1.2.3