Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thegeeklab/hugo-geekblog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Kaussow <mail@thegeeklab.de>2022-09-02 12:22:48 +0300
committerGitHub <noreply@github.com>2022-09-02 12:22:48 +0300
commitc95851d0a6b86a1e1d172b648fe40726cffacbaf (patch)
tree79a9279cddfb7c1f2becb25995ab331787ef61a9
parente4781b6eb789f56dc2b764052f933936f93b5569 (diff)
feat: add origin size to image shortcode (#306)v0.21.1
-rw-r--r--exampleSite/content/posts/post-with-images/index.md12
-rw-r--r--layouts/shortcodes/img.html9
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 }}
<div class="flex justify-center">
@@ -31,7 +32,11 @@
/>
<img
{{- if $lazyLoad }}{{ print " loading=\"lazy\"" | safeHTMLAttr }}{{- end }}
- src="{{ $size.large }}"
+ {{- if eq $customSize "origin" }}
+ src="{{ $size.origin }}"
+ {{- else }}
+ src="{{ $size.large }}"
+ {{- end }}
alt="{{ $caption }}"
/>
</picture>