Add format param

master
Will Faught 2 years ago
parent 6350366b7e
commit a47dea8864

@ -456,6 +456,7 @@ The `paige/gallery` shortcode provides a figure with a collection of images.
``` ```
{{< paige/gallery {{< paige/gallery
align="center" align="center"
format="webp"
height="10rem" height="10rem"
images="*.jpg" images="*.jpg"
justify="center" justify="center"
@ -481,6 +482,8 @@ Parameters:
<dl> <dl>
<dt><code>align</code></dt> <dt><code>align</code></dt>
<dd>Optional. String. Cross axis alignment. Must be <code>baseline</code>, <code>center</code>, <code>end</code>, <code>start</code>, or <code>stretch</code>. Must not be used when nested.</dd> <dd>Optional. String. Cross axis alignment. Must be <code>baseline</code>, <code>center</code>, <code>end</code>, <code>start</code>, or <code>stretch</code>. Must not be used when nested.</dd>
<dt><code>format</code></dt>
<dd>Optional. String. Image format. Must be <code>bmp</code>, <code>gif</code>, <code>jpg</code>, <code>png</code>, <code>tiff</code>, or <code>webp</code>. Must not be used with <code>method</code> or <code>options</code>.</dd>
<dt><code>height</code></dt> <dt><code>height</code></dt>
<dd>Optional. String. CSS value. Image height.</dd> <dd>Optional. String. CSS value. Image height.</dd>
<dt><code>images</code></dt> <dt><code>images</code></dt>
@ -508,6 +511,7 @@ The `paige/hero` shortcode provides a hero section.
``` ```
{{< paige/hero {{< paige/hero
alt="My alt" alt="My alt"
format="webp"
header="My header" header="My header"
height="10rem" height="10rem"
image="https://github.com/willfaught/paige" image="https://github.com/willfaught/paige"
@ -528,6 +532,8 @@ Parameters:
<dl> <dl>
<dt><code>alt</code></dt> <dt><code>alt</code></dt>
<dd>Optional. String. Plain text. Image alt.</dd> <dd>Optional. String. Plain text. Image alt.</dd>
<dt><code>format</code></dt>
<dd>Optional. String. Image format. Must be <code>bmp</code>, <code>gif</code>, <code>jpg</code>, <code>png</code>, <code>tiff</code>, or <code>webp</code>. Must not be used with <code>method</code> or <code>options</code>.</dd>
<dt><code>header</code></dt> <dt><code>header</code></dt>
<dd>Optional. String. Markdown. The header.</dd> <dd>Optional. String. Markdown. The header.</dd>
<dt><code>height</code></dt> <dt><code>height</code></dt>
@ -576,6 +582,7 @@ The `paige/image` shortcode provides a figure with an image.
``` ```
{{< paige/image {{< paige/image
alt="My alt" >}} alt="My alt" >}}
format="webp"
height="10rem" height="10rem"
link="https://github.com/willfaught/paige" link="https://github.com/willfaught/paige"
maxheight="10rem" maxheight="10rem"
@ -595,6 +602,8 @@ Parameters:
<dl> <dl>
<dt><code>alt</code></dt> <dt><code>alt</code></dt>
<dd>Optional. String. Plain text. Image alt.</dd> <dd>Optional. String. Plain text. Image alt.</dd>
<dt><code>format</code></dt>
<dd>Optional. String. Image format. Must be <code>bmp</code>, <code>gif</code>, <code>jpg</code>, <code>png</code>, <code>tiff</code>, or <code>webp</code>. Must not be used with <code>method</code> or <code>options</code>.</dd>
<dt><code>height</code></dt> <dt><code>height</code></dt>
<dd>Optional. String. CSS value. Image height.</dd> <dd>Optional. String. CSS value. Image height.</dd>
<dt><code>link</code></dt> <dt><code>link</code></dt>

@ -5,6 +5,7 @@
{{ $crossorigin := $params.crossorigin | default "anonymous" }} {{ $crossorigin := $params.crossorigin | default "anonymous" }}
{{ $fetchpriority := $params.fetchpriority }} {{ $fetchpriority := $params.fetchpriority }}
{{ $fingerprint := $params.fingerprint | default true }} {{ $fingerprint := $params.fingerprint | default true }}
{{ $format := $params.format }}
{{ $height := $params.height }} {{ $height := $params.height }}
{{ $loading := $params.loading | default "lazy" }} {{ $loading := $params.loading | default "lazy" }}
{{ $maxheight := $params.maxheight }} {{ $maxheight := $params.maxheight }}
@ -31,6 +32,11 @@
{{ end }} {{ end }}
{{ with $resource }} {{ 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 and $method $options }}
{{ if eq $method "crop" }} {{ if eq $method "crop" }}
{{ $resource = $resource.Crop $options }} {{ $resource = $resource.Crop $options }}

@ -1,4 +1,5 @@
{{ $align := .Get "align" | default "center" }} {{ $align := .Get "align" | default "center" }}
{{ $format := .Get "format" }}
{{ $height := .Get "height" }} {{ $height := .Get "height" }}
{{ $images := .Get 0 | default (.Get "images") }} {{ $images := .Get 0 | default (.Get "images") }}
{{ $justify := .Get "justify" | default "center" }} {{ $justify := .Get "justify" | default "center" }}
@ -44,6 +45,7 @@
{{ partial "paige/a.html" (dict {{ partial "paige/a.html" (dict
"content" (partial "paige/img.html" (dict "content" (partial "paige/img.html" (dict
"class" "img-fluid" "class" "img-fluid"
"format" $format
"height" $height "height" $height
"maxheight" $maxheight "maxheight" $maxheight
"maxwidth" $maxwidth "maxwidth" $maxwidth
@ -68,6 +70,7 @@
{{ partial "paige/a.html" (dict {{ partial "paige/a.html" (dict
"content" (partial "paige/img.html" (dict "content" (partial "paige/img.html" (dict
"class" "img-fluid" "class" "img-fluid"
"format" $format
"height" $height "height" $height
"maxheight" $maxheight "maxheight" $maxheight
"maxwidth" $maxwidth "maxwidth" $maxwidth

@ -1,5 +1,6 @@
{{ $alt := .Get "alt" }} {{ $alt := .Get "alt" }}
{{ $content := .Inner | replaceRE "^\n" "" | replaceRE "\n$" "" | markdownify }} {{ $content := .Inner | replaceRE "^\n" "" | replaceRE "\n$" "" | markdownify }}
{{ $format := .Get "format" }}
{{ $header := .Get "header" | markdownify }} {{ $header := .Get "header" | markdownify }}
{{ $height := .Get "height" }} {{ $height := .Get "height" }}
{{ $image := .Get "image" }} {{ $image := .Get "image" }}
@ -29,6 +30,7 @@
"class" $imageclass "class" $imageclass
"height" $height "height" $height
"fetchpriority" "high" "fetchpriority" "high"
"format" $format
"loading" "eager" "loading" "eager"
"maxheight" $maxheight "maxheight" $maxheight
"maxwidth" $maxwidth "maxwidth" $maxwidth

@ -1,4 +1,5 @@
{{ $alt := .Get "alt" }} {{ $alt := .Get "alt" }}
{{ $format := .Get "format" }}
{{ $height := .Get "height" }} {{ $height := .Get "height" }}
{{ $link := .Get "link" }} {{ $link := .Get "link" }}
{{ $maxheight := .Get "maxheight" }} {{ $maxheight := .Get "maxheight" }}
@ -16,6 +17,7 @@
{{ $content := partial "paige/img.html" (dict {{ $content := partial "paige/img.html" (dict
"alt" $alt "alt" $alt
"class" "img-fluid" "class" "img-fluid"
"format" $format
"height" $height "height" $height
"maxheight" $maxheight "maxheight" $maxheight
"maxwidth" $maxwidth "maxwidth" $maxwidth

Loading…
Cancel
Save