From d5b8ccfda9f56c9345c30a855c453a662b3cf7b1 Mon Sep 17 00:00:00 2001 From: Andreas Deininger Date: Mon, 10 Oct 2022 21:35:05 +0200 Subject: [PATCH] Shortcode imgproc: add crop command --- layouts/shortcodes/imgproc.html | 4 +++- .../content/en/docs/adding-content/shortcodes/index.md | 6 +++--- 2 files changed, 6 insertions(+), 4 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..33ce510c8f 100644 --- a/userguide/content/en/docs/adding-content/shortcodes/index.md +++ b/userguide/content/en/docs/adding-content/shortcodes/index.md @@ -204,7 +204,7 @@ 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