mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-22 05:00: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
@ -61,11 +61,12 @@ If you need more flexibility for your embedded images, you could use the `img` s
|
|||||||
## Attributes
|
## Attributes
|
||||||
|
|
||||||
| Name | Description | default |
|
| Name | Description | default |
|
||||||
| ---- | ------------------------------------------------------------ | ----------------- |
|
| ------ | -------------------------------------------------------------------------------- | ----------------- |
|
||||||
| name | name of the image resource defined in your front matter | empty |
|
| name | name of the image resource defined in your front matter | empty |
|
||||||
| alt | description for displayed image | resource `.Title` |
|
| alt | description for displayed image | resource `.Title` |
|
||||||
| size | Thumbnail size (origin\|profile\|tiny\|small\|medium\|large) | empty |
|
| size | Thumbnail size (origin\|profile\|tiny\|small\|medium\|large) | empty |
|
||||||
| lazy | enable or disable image lazy loading | true |
|
| 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
|
## Usage
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{{- $source := ($.Page.Resources.ByType "image").GetMatch (printf "%s" (.Get "name")) }}
|
{{- $source := ($.Page.Resources.ByType "image").GetMatch (printf "%s" (.Get "name")) }}
|
||||||
{{- $customAlt := .Get "alt" }}
|
{{- $customAlt := .Get "alt" }}
|
||||||
{{- $customSize := .Get "size" | lower }}
|
{{- $customSize := .Get "size" | lower }}
|
||||||
|
{{- $customAnchor := default "smart" (.Get "anchor") | title }}
|
||||||
{{- $lazyLoad := default (default true $.Site.Params.geekblogImageLazyLoading) (.Get "lazy") }}
|
{{- $lazyLoad := default (default true $.Site.Params.geekblogImageLazyLoading) (.Get "lazy") }}
|
||||||
{{- $data := newScratch }}
|
{{- $data := newScratch }}
|
||||||
|
|
||||||
@ -16,7 +17,7 @@
|
|||||||
{{- $data.SetInMap "size" "medium" "1200" }}
|
{{- $data.SetInMap "size" "medium" "1200" }}
|
||||||
{{- $data.SetInMap "size" "large" "1800" }}
|
{{- $data.SetInMap "size" "large" "1800" }}
|
||||||
{{- else }}
|
{{- 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" "tiny" (.Resize "320x").Permalink }}
|
||||||
{{- $data.SetInMap "size" "small" (.Resize "600x").Permalink }}
|
{{- $data.SetInMap "size" "small" (.Resize "600x").Permalink }}
|
||||||
{{- $data.SetInMap "size" "medium" (.Resize "1200x").Permalink }}
|
{{- $data.SetInMap "size" "medium" (.Resize "1200x").Permalink }}
|
||||||
|
Loading…
Reference in New Issue
Block a user