From e00d6c708309c513e2fa4f6b76e6367e7049b73a Mon Sep 17 00:00:00 2001 From: Toshaan Bharvani Date: Sun, 9 Jan 2022 16:52:14 +0100 Subject: [PATCH] add image shortcode for image optimization in content Signed-off-by: Toshaan Bharvani --- .../layouts/shortcodes/image.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 themes/openpowerfoundation/layouts/shortcodes/image.html diff --git a/themes/openpowerfoundation/layouts/shortcodes/image.html b/themes/openpowerfoundation/layouts/shortcodes/image.html new file mode 100644 index 0000000..4225d9e --- /dev/null +++ b/themes/openpowerfoundation/layouts/shortcodes/image.html @@ -0,0 +1,15 @@ +{{ $src := .Get "src" }} +{{ $imagesrc := (printf "images/%s" $src) }} +{{ $width := .Get "width" }} +{{ $height := .Get "height" }} +{{ $imageresource := resources.Get $imagesrc }} +{{ if eq $width "" }} + {{ $width = "500" }} +{{ end }} +{{ if eq $height "" }} + {{ $height = "500" }} +{{ end }} +{{ $imageprocessing := (printf "%sx%s %s" $width $height "webp") }} +{{ $image := $imageresource.Fit $imageprocessing }} + +