From b9876a864099359728db74de33ce5fdbae1d08c1 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Fri, 2 Sep 2022 10:58:44 +0200 Subject: [PATCH] feat: add origin size to image shortcode (#490) --- exampleSite/content/en/shortcodes/images/_index.md | 12 ++++++------ layouts/shortcodes/img.html | 11 ++++++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/exampleSite/content/en/shortcodes/images/_index.md b/exampleSite/content/en/shortcodes/images/_index.md index 29d06a0..60038eb 100644 --- a/exampleSite/content/en/shortcodes/images/_index.md +++ b/exampleSite/content/en/shortcodes/images/_index.md @@ -43,12 +43,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 5a4d647..f630d83 100644 --- a/layouts/shortcodes/img.html +++ b/layouts/shortcodes/img.html @@ -6,18 +6,19 @@ {{- 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 }}