From 0a74210e2b322f0145e5aca3f386e982d0127960 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Thu, 13 Feb 2025 19:55:54 -0800 Subject: [PATCH] theme: Remove readfile shortcode --- .../image-processing/index.md | 38 +++++----------- layouts/shortcodes/imgproc.html | 45 ++++++++++--------- layouts/shortcodes/readfile.html | 1 - 3 files changed, 36 insertions(+), 48 deletions(-) delete mode 100644 layouts/shortcodes/readfile.html diff --git a/content/en/content-management/image-processing/index.md b/content/en/content-management/image-processing/index.md index 50e4b1e72..fa97edca6 100644 --- a/content/en/content-management/image-processing/index.md +++ b/content/en/content-management/image-processing/index.md @@ -401,31 +401,17 @@ See [github.com/disintegration/imaging] for the complete list of resampling filt _The photo of the sunset used in the examples below is Copyright [Bjørn Erik Pedersen](https://commons.wikimedia.org/wiki/User:Bep) (Creative Commons Attribution-Share Alike 4.0 International license)_ -{{< imgproc "sunset.jpg" "resize 300x" />}} +{{< imgproc path="sunset.jpg" spec="resize 480x" alt="A sunset" />}} -{{< imgproc "sunset.jpg" "fill 90x120 left" />}} +{{< imgproc path="sunset.jpg" spec="fill 120x150 left" alt="A sunset" />}} -{{< imgproc "sunset.jpg" "fill 90x120 right" />}} +{{< imgproc path="sunset.jpg" spec="fill 120x150 right" alt="A sunset" />}} -{{< imgproc "sunset.jpg" "fit 90x90" />}} +{{< imgproc path="sunset.jpg" spec="fit 120x120" alt="A sunset" />}} -{{< imgproc "sunset.jpg" "crop 250x250 center" />}} +{{< imgproc path="sunset.jpg" spec="crop 240x240 center" alt="A sunset" />}} -{{< imgproc "sunset.jpg" "resize 300x q10" />}} - -This is the shortcode used to generate the examples above: - -{{< readfile file=layouts/shortcodes/imgproc.html highlight=go-html-template >}} - -Call the shortcode from your Markdown like this: - -```go-html-template -{{}} -``` - -{{% note %}} -Note the self-closing shortcode syntax above. You may call the `imgproc` shortcode with or without **inner content**. -{{% /note %}} +{{< imgproc path="sunset.jpg" spec="resize 360x q10" alt="A sunset" />}} ## Imaging configuration @@ -474,11 +460,11 @@ excludeFields includeFields : Regular expression matching the EXIF tags to include in the `.Tags` collection. Default is `""`. To include all available tags, set this value to `".*"`. -{{% note %}} -To improve performance and decrease cache size, Hugo excludes the following tags: `ColorSpace`, `Contrast`, `Exif`, `Exposure[M|P|B]`, `Flash`, `GPS`, `JPEG`, `Metering`, `Resolution`, `Saturation`, `Sensing`, `Sharp`, and `WhiteBalance`. + {{% note %}} + To improve performance and decrease cache size, Hugo excludes the following tags: `ColorSpace`, `Contrast`, `Exif`, `Exposure[M|P|B]`, `Flash`, `GPS`, `JPEG`, `Metering`, `Resolution`, `Saturation`, `Sensing`, `Sharp`, and `WhiteBalance`. -To control tag availability, change the `excludeFields` or `includeFields` settings as described above. -{{% /note %}} + To control tag availability, change the `excludeFields` or `includeFields` settings as described above. + {{% /note %}} ## Smart cropping of images @@ -486,9 +472,9 @@ By default, Hugo uses the [Smartcrop] library when cropping images with the `Cro Examples using the sunset image from above: -{{< imgproc "sunset.jpg" "fill 200x200 smart" />}} +{{< imgproc path="sunset.jpg" spec="fill 200x200 smart" alt="A sunset" />}} -{{< imgproc "sunset.jpg" "crop 200x200 smart" />}} +{{< imgproc path="sunset.jpg" spec="crop 200x200 smart" alt="A sunset" />}} ## Image processing performance consideration diff --git a/layouts/shortcodes/imgproc.html b/layouts/shortcodes/imgproc.html index c09133ba8..59734d2a0 100644 --- a/layouts/shortcodes/imgproc.html +++ b/layouts/shortcodes/imgproc.html @@ -1,37 +1,40 @@ {{- /* -Renders the given image using the given process specification. + Renders the given image using the given process specification. -@param {string} (positional parameter 0) The path to the image, relative to the current page. The image must be a page resource. -@param {string}} (positional parameter 1) The image processing specification. + @param {string} path The path to the image, either a page resource or a global resource. + @param {string} spec The image processing specification. + @param {string} alt The alt attribute of the img element. -@returns template.HTML + @returns template.HTML -@example {{< imgproc "sunset.jpg" "resize 300x" />}} + @example {{< imgproc path="sunset.jpg" spec="resize 300x" alt="A sunset" / +>}} */}} - -{{- with $.Get 0 }} - {{- with $i := $.Page.Resources.Get . }} - {{- with $spec := $.Get 1 }} +{{- with $.Get "path" }} + {{- with $i := or ($.Page.Resources.Get .) (resources.Get .) }} + {{- with $spec := $.Get "spec" }} {{- with $i.Process . }} -
- -
- - {{- with $.Inner }} - {{ . }} - {{- else }} - {{ $spec }} - {{- end }} - +
+ {{ $.Get `alt` }} +
+ {{- with $.Inner }} + {{ . }} + {{- else }} + {{ $spec }} + {{- end }}
{{- end }} {{- else }} - {{- errorf "The %q shortcode requires a positional parameter (1) containing the image processing specification. See %s" $.Name $.Position }} + {{- errorf "The %q shortcode requires a 'spec' argument containing the image processing specification. See %s" $.Name $.Position }} {{- end }} {{- else }} {{- errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }} {{- end }} {{- else }} - {{- errorf "The %q shortcode requires a positional parameter (0) indicating the image path, relative to the current page. See %s" $.Name $.Position }} + {{- errorf "The %q shortcode requires a 'path' argument indicating the image path. The image must be a page resource or a global resource. See %s" $.Name $.Position }} {{- end }} diff --git a/layouts/shortcodes/readfile.html b/layouts/shortcodes/readfile.html deleted file mode 100644 index 1a7d6a320..000000000 --- a/layouts/shortcodes/readfile.html +++ /dev/null @@ -1 +0,0 @@ -TODO readfile.html