From a497c22caa53489a9155e69a90147c3b53ccb1cf Mon Sep 17 00:00:00 2001 From: Andreas Deininger Date: Fri, 3 Feb 2023 13:46:37 +0100 Subject: [PATCH] Shortcode imgproc: add crop command (#1272) --- layouts/shortcodes/imgproc.html | 4 +++- .../content/en/docs/adding-content/shortcodes/index.md | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/layouts/shortcodes/imgproc.html b/layouts/shortcodes/imgproc.html index 550dc7a4fa..6c5a211f90 100644 --- a/layouts/shortcodes/imgproc.html +++ b/layouts/shortcodes/imgproc.html @@ -7,8 +7,10 @@ {{ .Scratch.Set "image" ($original.Resize $options) }} {{ else if eq $command "Fill"}} {{ .Scratch.Set "image" ($original.Fill $options) }} +{{ else if eq $command "Crop"}} +{{ .Scratch.Set "image" ($original.Crop $options) }} {{ else }} -{{ errorf "Invalid image processing command: Must be one of Fit, Fill or Resize."}} +{{ errorf "Invalid image processing command: Must be one of Fit, Fill, Crop or Resize."}} {{ end }} {{ $image := .Scratch.Get "image" }}
diff --git a/userguide/content/en/docs/adding-content/shortcodes/index.md b/userguide/content/en/docs/adding-content/shortcodes/index.md index 2afe34f499..2eda403c90 100644 --- a/userguide/content/en/docs/adding-content/shortcodes/index.md +++ b/userguide/content/en/docs/adding-content/shortcodes/index.md @@ -199,12 +199,12 @@ The **imgproc** shortcode finds an image in the current [Page Bundle](/docs/addi ```go-html-template {{}} -Norway Spruce Picea abies shoot with foliage buds. +Norway Spruce Picea abies shoot with foliage buds. {{}} ``` {{< imgproc spruce Fill "400x450" >}} -Norway Spruce Picea abies shoot with foliage buds. +Norway Spruce Picea abies shoot with foliage buds. {{< /imgproc >}} The example above has also a byline with photo attribution added. When using illustrations with a free license from [WikiMedia](https://commons.wikimedia.org/) and similar, you will in most situations need a way to attribute the author or licensor. You can add metadata to your page resources in the page front matter. The `byline` param is used by convention in this theme: @@ -245,8 +245,8 @@ resources: | Parameter | Description | | ----------------: |------------| | 1 | The image filename or enough of it to identify it (we do Glob matching) -| 2 | Command. One of `Fit`, `Resize` or `Fill`. See [Image Processing Methods](https://gohugo.io/content-management/image-processing/#image-processing-methods). -| 3 | Processing options, e.g. `400x450`. See [Image Processing Options](https://gohugo.io/content-management/image-processing/#image-processing-methods). +| 2 | Command. One of `Fit`, `Resize`, `Fill` or `Crop`. See [Image Processing Methods](https://gohugo.io/content-management/image-processing/#image-processing-methods). +| 3 | Processing options, e.g. `400x450 r180`. See [Image Processing Options](https://gohugo.io/content-management/image-processing/#image-processing-options). ### swaggerui