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

github.com/thegeeklab/hugo-geekdoc.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 11:58:44 +0300
committerGitHub <noreply@github.com>2022-09-02 11:58:44 +0300
commitb9876a864099359728db74de33ce5fdbae1d08c1 (patch)
tree2fe0baafe066b9a2bcc92f8f361d98004f5b2657
parent2e1098d3e3e8b0a7da29e62308ac9071a8ca771a (diff)
feat: add origin size to image shortcode (#490)v0.35.1
-rw-r--r--exampleSite/content/en/shortcodes/images/_index.md12
-rw-r--r--layouts/shortcodes/img.html11
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 }}
<div class="flex justify-center">
<figure
- class="gdoc-post__figure
+ class="gdoc-markdown__figure
{{- if eq $customSize "profile" }}{{ print " gdoc-post__figure--round" }}{{ end }}"
>
<a class="gdoc-markdown__link--raw" href="{{ .Permalink }}">
@@ -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>