mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-21 12:40:39 +00:00
feat: add option to change the crop box anchor in img shortcode (#466)
This commit is contained in:
parent
e75703c18a
commit
45398ae676
@ -60,12 +60,13 @@ If you need more flexibility for your embedded images, you could use the `img` s
|
||||
|
||||
## Attributes
|
||||
|
||||
| Name | Description | default |
|
||||
| ---- | ------------------------------------------------------------ | ----------------- |
|
||||
| name | name of the image resource defined in your front matter | empty |
|
||||
| alt | description for displayed image | resource `.Title` |
|
||||
| size | Thumbnail size (origin\|profile\|tiny\|small\|medium\|large) | empty |
|
||||
| lazy | enable or disable image lazy loading | true |
|
||||
| Name | Description | default |
|
||||
| ------ | -------------------------------------------------------------------------------- | ----------------- |
|
||||
| name | name of the image resource defined in your front matter | empty |
|
||||
| alt | description for displayed image | resource `.Title` |
|
||||
| size | Thumbnail size (origin\|profile\|tiny\|small\|medium\|large) | empty |
|
||||
| lazy | enable or disable image lazy loading | true |
|
||||
| anchor | anchor to determine the placement of the crop box (only used for `profile` size) | smart |
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
{{- $source := ($.Page.Resources.ByType "image").GetMatch (printf "%s" (.Get "name")) }}
|
||||
{{- $customAlt := .Get "alt" }}
|
||||
{{- $customSize := .Get "size" | lower }}
|
||||
{{- $customAnchor := default "smart" (.Get "anchor") | title }}
|
||||
{{- $lazyLoad := default (default true $.Site.Params.geekblogImageLazyLoading) (.Get "lazy") }}
|
||||
{{- $data := newScratch }}
|
||||
|
||||
@ -16,7 +17,7 @@
|
||||
{{- $data.SetInMap "size" "medium" "1200" }}
|
||||
{{- $data.SetInMap "size" "large" "1800" }}
|
||||
{{- else }}
|
||||
{{- $data.SetInMap "size" "profile" (.Fill "180x180 Smart").Permalink }}
|
||||
{{- $data.SetInMap "size" "profile" (.Fill (printf "180x180 %s" $customAnchor)).Permalink }}
|
||||
{{- $data.SetInMap "size" "tiny" (.Resize "320x").Permalink }}
|
||||
{{- $data.SetInMap "size" "small" (.Resize "600x").Permalink }}
|
||||
{{- $data.SetInMap "size" "medium" (.Resize "1200x").Permalink }}
|
||||
|
Loading…
Reference in New Issue
Block a user