From 80344a5c6c866faee2d0d0e2dae20a81900242c1 Mon Sep 17 00:00:00 2001 From: Joe Hutchinson Date: Mon, 21 Jan 2019 11:24:09 -0500 Subject: [PATCH] Improve image and smallimg support of webp --- layouts/shortcodes/image.html | 6 ++++-- layouts/shortcodes/smallimg.html | 28 +++++++++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/layouts/shortcodes/image.html b/layouts/shortcodes/image.html index d7c0c10..acb26e8 100644 --- a/layouts/shortcodes/image.html +++ b/layouts/shortcodes/image.html @@ -1,5 +1,7 @@ - - + {{ if (fileExists (printf "%s/%s" "static" (replace (index .Params "src") (path.Ext (index .Params "src")) ".webp"))) -}} + + {{- end }} + {{ index .Params \ No newline at end of file diff --git a/layouts/shortcodes/smallimg.html b/layouts/shortcodes/smallimg.html index 4cae5b7..3610345 100644 --- a/layouts/shortcodes/smallimg.html +++ b/layouts/shortcodes/smallimg.html @@ -1,11 +1,17 @@ -{{ index .Params \ No newline at end of file + + {{ if (fileExists (printf "%s/%s" "static" (replace (index .Params "src") (path.Ext (index .Params "src")) ".webp"))) -}} + + {{- end }} + + {{ index .Params + \ No newline at end of file