diff --git a/exampleSite/content/posts/post-with-images/index.md b/exampleSite/content/posts/post-with-images/index.md index 4fa00cb..17d02a5 100644 --- a/exampleSite/content/posts/post-with-images/index.md +++ b/exampleSite/content/posts/post-with-images/index.md @@ -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 diff --git a/layouts/shortcodes/img.html b/layouts/shortcodes/img.html index f435bc6..f6dcbd8 100644 --- a/layouts/shortcodes/img.html +++ b/layouts/shortcodes/img.html @@ -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 }}