diff --git a/README.md b/README.md index d9e766e3..1df4afcd 100644 --- a/README.md +++ b/README.md @@ -602,6 +602,7 @@ The `paige/image` shortcode provides a figure with a centered image. maxwidth="10rem" method="resize" options="550x webp picture Lanczos" + raw=false src="me.jpg" title="My title" width="10rem" >}} @@ -630,6 +631,8 @@ Parameters:
Optional. String. Hugo image processing method. Must be crop, fill, fit, or resize. Must be specified with options. See Image Processing Methods.
options
Optional. String. Hugo image processing options. Must be specified with method. See Image Processing Options.
+
raw
+
Optional. Boolean. Whether to reference an image without copying it. Default is false.
src
Required. Position 0. String. URL. Image URL.
title
@@ -661,10 +664,12 @@ The `paige/gallery` shortcode provides a figure with a centered list of images. {{< paige/gallery image="me.jpg" caption="My caption" + raw=false >}} {{< paige/gallery image="you.jpg" caption="My caption" + raw=false >}} {{< /paige/gallery >}} ``` @@ -694,6 +699,8 @@ Parameters:
Optional. String. Hugo image processing method. Must be crop, fill, fit, or resize. Default is resize. Must be specified with options. See Image Processing Methods.
options
Optional. String. Hugo image processing options. Default is 550x webp picture Lanczos. Must be specified with method. See Image Processing Options.
+
raw
+
Optional. Boolean. Whether to reference an image without copying it. Default is false.
type
Optional. String. Type of layout. Must be grid or list. Default is list.
width
diff --git a/exampleSite/content/blog/gallery-shortcode/index.md b/exampleSite/content/blog/gallery-shortcode/index.md index 88c58d75..c341c991 100644 --- a/exampleSite/content/blog/gallery-shortcode/index.md +++ b/exampleSite/content/blog/gallery-shortcode/index.md @@ -9,6 +9,22 @@ title: Gallery Shortcode See the images in the example site to understand how the below file patterns work. Resize the viewport as narrow and wide as you can to see the responsiveness. +Code: + +```go-text-template +{{}} + {{}} +{{}} +``` + +Result: + +{{< paige/gallery >}} + {{< paige/gallery image="https://picsum.photos/400/300.webp" raw=true />}} +{{< /paige/gallery >}} + +--- + ## Rows layout Code: diff --git a/layouts/partials/paige/image-figure.html b/layouts/partials/paige/image-figure.html index 1c95bbde..3dc765bf 100644 --- a/layouts/partials/paige/image-figure.html +++ b/layouts/partials/paige/image-figure.html @@ -9,6 +9,7 @@ {{ $method := .method }} {{ $options := .options }} {{ $page := .page }} +{{ $raw := .raw }} {{ $resource := .resource }} {{ $src := .src }} {{ $table := .table }} @@ -21,6 +22,7 @@ "method" $method "options" $options "page" $page + "raw" $raw "resource" $resource "src" $src "title" $title diff --git a/layouts/shortcodes/paige/gallery.html b/layouts/shortcodes/paige/gallery.html index 80d55360..b4cc7dc0 100644 --- a/layouts/shortcodes/paige/gallery.html +++ b/layouts/shortcodes/paige/gallery.html @@ -8,25 +8,33 @@ {{ $maxwidth := .Get "maxwidth" }} {{ $method := .Get "method" | default "resize" }} {{ $options := .Get "options" | default "550x webp picture Lanczos" }} +{{ $raw := .Get "raw" }} {{ $type := .Get "type" | default "rows" }} {{ $width := .Get "width" }} {{ if $image }} - {{ $resource := partial "paige/func-resource.html" (dict - "page" .Page - "url" $image - ) }} + {{ $link := $image }} + {{ $resource := "" }} + + {{ if not $raw }} + {{ $resource = partial "paige/func-resource.html" (dict + "page" .Page + "url" $image + ) }} + {{ $link = $resource.RelPermalink }} + {{ end }} {{ partial "paige/image-figure.html" (dict "caption" $caption "compact" true "height" $height - "link" $resource.RelPermalink + "link" $link "maxheight" $maxheight "maxwidth" $maxwidth "method" $method "options" $options "page" .Page + "raw" $raw "resource" $resource "src" $image "table" true diff --git a/layouts/shortcodes/paige/image.html b/layouts/shortcodes/paige/image.html index a1722a3d..6d0058cd 100644 --- a/layouts/shortcodes/paige/image.html +++ b/layouts/shortcodes/paige/image.html @@ -8,6 +8,7 @@ {{ $maxwidth := .Get "maxwidth" }} {{ $method := .Get "method" }} {{ $options := .Get "options" }} +{{ $raw := .Get "raw" }} {{ $src := .Get 0 | default (.Get "src") }} {{ $title := .Get "title" }} {{ $width := .Get "width" }} @@ -23,6 +24,7 @@ "maxwidth" $maxwidth "method" $method "options" $options + "raw" $raw "src" $src "title" $title "width" $width