Skip to content

Commit

Permalink
Shortcode imgproc: add crop command
Browse files Browse the repository at this point in the history
  • Loading branch information
deining committed Oct 29, 2022
1 parent d9bf98b commit f887686
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion layouts/shortcodes/imgproc.html
Original file line number Diff line number Diff line change
Expand Up @@ -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" }}
<figure class="card rounded p-2 td-post-card mb-4 mt-4" style="max-width: {{ add $image.Width 10 }}px">
Expand Down
6 changes: 3 additions & 3 deletions userguide/content/en/docs/adding-content/shortcodes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <i>Picea abies</i> 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:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit f887686

Please sign in to comment.