From c95851d0a6b86a1e1d172b648fe40726cffacbaf Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Fri, 2 Sep 2022 11:22:48 +0200 Subject: [PATCH] feat: add origin size to image shortcode (#306) --- exampleSite/content/posts/post-with-images/index.md | 12 ++++++------ layouts/shortcodes/img.html | 9 +++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/exampleSite/content/posts/post-with-images/index.md b/exampleSite/content/posts/post-with-images/index.md index f4e4e1d..dbada6f 100644 --- a/exampleSite/content/posts/post-with-images/index.md +++ b/exampleSite/content/posts/post-with-images/index.md @@ -55,12 +55,12 @@ 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 (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 | ## Usage diff --git a/layouts/shortcodes/img.html b/layouts/shortcodes/img.html index 436feb6..ffbc6c0 100644 --- a/layouts/shortcodes/img.html +++ b/layouts/shortcodes/img.html @@ -6,13 +6,14 @@ {{- with $source }} {{- $caption := default .Title $customAlt }} + {{- $origin := .Permalink }} {{- $profile := (.Fill "180x180 Center").Permalink }} {{- $tiny := (.Resize "320x").Permalink }} {{- $small := (.Resize "600x").Permalink }} {{- $medium := (.Resize "1200x").Permalink }} {{- $large := (.Resize "1800x").Permalink }} - {{- $size := dict "profile" $profile "tiny" $tiny "small" $small "medium" $medium "large" $large }} + {{- $size := dict "origin" $origin "profile" $profile "tiny" $tiny "small" $small "medium" $medium "large" $large }}
@@ -31,7 +32,11 @@ /> {{ $caption }}