diff --git a/README.md b/README.md index b8383de2..62ca0a81 100644 --- a/README.md +++ b/README.md @@ -456,6 +456,7 @@ The `paige/gallery` shortcode provides a figure with a collection of images. ``` {{< paige/gallery align="center" + format="webp" height="10rem" images="*.jpg" justify="center" @@ -481,6 +482,8 @@ Parameters:
align
Optional. String. Cross axis alignment. Must be baseline, center, end, start, or stretch. Must not be used when nested.
+
format
+
Optional. String. Image format. Must be bmp, gif, jpg, png, tiff, or webp. Must not be used with method or options.
height
Optional. String. CSS value. Image height.
images
@@ -508,6 +511,7 @@ The `paige/hero` shortcode provides a hero section. ``` {{< paige/hero alt="My alt" + format="webp" header="My header" height="10rem" image="https://github.com/willfaught/paige" @@ -528,6 +532,8 @@ Parameters:
alt
Optional. String. Plain text. Image alt.
+
format
+
Optional. String. Image format. Must be bmp, gif, jpg, png, tiff, or webp. Must not be used with method or options.
header
Optional. String. Markdown. The header.
height
@@ -576,6 +582,7 @@ The `paige/image` shortcode provides a figure with an image. ``` {{< paige/image alt="My alt" >}} + format="webp" height="10rem" link="https://github.com/willfaught/paige" maxheight="10rem" @@ -595,6 +602,8 @@ Parameters:
alt
Optional. String. Plain text. Image alt.
+
format
+
Optional. String. Image format. Must be bmp, gif, jpg, png, tiff, or webp. Must not be used with method or options.
height
Optional. String. CSS value. Image height.
link
diff --git a/layouts/partials/paige/img.html b/layouts/partials/paige/img.html index 3696d96a..e09e0c94 100644 --- a/layouts/partials/paige/img.html +++ b/layouts/partials/paige/img.html @@ -5,6 +5,7 @@ {{ $crossorigin := $params.crossorigin | default "anonymous" }} {{ $fetchpriority := $params.fetchpriority }} {{ $fingerprint := $params.fingerprint | default true }} +{{ $format := $params.format }} {{ $height := $params.height }} {{ $loading := $params.loading | default "lazy" }} {{ $maxheight := $params.maxheight }} @@ -31,6 +32,11 @@ {{ end }} {{ with $resource }} + {{ if and (not $method) (not $options) $format }} + {{ $method = "resize" }} + {{ $options = printf "%dx%d %s" $resource.Width $resource.Height $format }} + {{ end }} + {{ if and $method $options }} {{ if eq $method "crop" }} {{ $resource = $resource.Crop $options }} diff --git a/layouts/shortcodes/paige/gallery.html b/layouts/shortcodes/paige/gallery.html index b18ec886..d630b0f7 100644 --- a/layouts/shortcodes/paige/gallery.html +++ b/layouts/shortcodes/paige/gallery.html @@ -1,4 +1,5 @@ {{ $align := .Get "align" | default "center" }} +{{ $format := .Get "format" }} {{ $height := .Get "height" }} {{ $images := .Get 0 | default (.Get "images") }} {{ $justify := .Get "justify" | default "center" }} @@ -44,6 +45,7 @@ {{ partial "paige/a.html" (dict "content" (partial "paige/img.html" (dict "class" "img-fluid" + "format" $format "height" $height "maxheight" $maxheight "maxwidth" $maxwidth @@ -68,6 +70,7 @@ {{ partial "paige/a.html" (dict "content" (partial "paige/img.html" (dict "class" "img-fluid" + "format" $format "height" $height "maxheight" $maxheight "maxwidth" $maxwidth diff --git a/layouts/shortcodes/paige/hero.html b/layouts/shortcodes/paige/hero.html index 853ad880..c5bb7a9d 100644 --- a/layouts/shortcodes/paige/hero.html +++ b/layouts/shortcodes/paige/hero.html @@ -1,5 +1,6 @@ {{ $alt := .Get "alt" }} {{ $content := .Inner | replaceRE "^\n" "" | replaceRE "\n$" "" | markdownify }} +{{ $format := .Get "format" }} {{ $header := .Get "header" | markdownify }} {{ $height := .Get "height" }} {{ $image := .Get "image" }} @@ -29,6 +30,7 @@ "class" $imageclass "height" $height "fetchpriority" "high" + "format" $format "loading" "eager" "maxheight" $maxheight "maxwidth" $maxwidth diff --git a/layouts/shortcodes/paige/image.html b/layouts/shortcodes/paige/image.html index 44fadafb..e310ff04 100644 --- a/layouts/shortcodes/paige/image.html +++ b/layouts/shortcodes/paige/image.html @@ -1,4 +1,5 @@ {{ $alt := .Get "alt" }} +{{ $format := .Get "format" }} {{ $height := .Get "height" }} {{ $link := .Get "link" }} {{ $maxheight := .Get "maxheight" }} @@ -16,6 +17,7 @@ {{ $content := partial "paige/img.html" (dict "alt" $alt "class" "img-fluid" + "format" $format "height" $height "maxheight" $maxheight "maxwidth" $maxwidth