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

github.com/peaceiris/hugo-theme-iris.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShohei Ueda <30958501+peaceiris@users.noreply.github.com>2021-06-13 11:41:00 +0300
committerGitHub <noreply@github.com>2021-06-13 11:41:00 +0300
commit0d5ba91a93fbeb7eb70247db1f7d27ae28bfe3cf (patch)
tree1b4d5b501a682a66cedd21383a3952ce78496bf8 /layouts
parent1379bb6e5267bbeaa33e4c646cf690c026d26c91 (diff)
fix: gitignore rule (#369)
* fix: fetched image handling
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/_markup/render-image.html10
-rw-r--r--layouts/partials/eyecatch.html9
-rw-r--r--layouts/shortcodes/circle.html51
3 files changed, 48 insertions, 22 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html
index 080f997e..3b0ee458 100644
--- a/layouts/_default/_markup/render-image.html
+++ b/layouts/_default/_markup/render-image.html
@@ -3,11 +3,13 @@
{{ $caption = . | safeHTML }}
{{ end }}
-{{ $hashedDestination := sha256 $.Destination }}
-{{ $extension := path.Ext $.Destination }}
+{{ $imageSrc := $.Destination }}
+{{ $hashedDestination := sha256 $imageSrc }}
+{{ $extension := path.Ext $imageSrc }}
{{ $localPath := delimit (slice "images/" $hashedDestination $extension) "" }}
-{{ $imagePath := $.Destination }}
-{{ if (fileExists $localPath) }}
+{{ $assetPath := delimit (slice "assets/" $localPath) "" }}
+{{ $imagePath := $imageSrc }}
+{{ if (fileExists $assetPath) }}
{{ $imagePath = $localPath }}
{{ end }}
diff --git a/layouts/partials/eyecatch.html b/layouts/partials/eyecatch.html
index fd6639ba..a5c37912 100644
--- a/layouts/partials/eyecatch.html
+++ b/layouts/partials/eyecatch.html
@@ -1,12 +1,13 @@
{{ with $.Params.eyecatch }}
- {{ $hashedDestination := sha256 $.Params.eyecatch }}
- {{ $extension := path.Ext $.Params.eyecatch }}
+ {{ $imageSrc := $.Params.eyecatch }}
+ {{ $hashedDestination := sha256 $imageSrc }}
+ {{ $extension := path.Ext $imageSrc }}
{{ $localPath := delimit (slice "images/" $hashedDestination $extension) "" }}
{{ $assetPath := delimit (slice "assets/" $localPath) "" }}
- {{ $imagePath := $.Params.eyecatch }}
+ {{ $imagePath := $imageSrc }}
{{ if (fileExists $assetPath) }}
- {{ $imagePath = $localPath }}
+ {{ $imagePath = $localPath }}
{{ end }}
{{ with resources.Get $imagePath }}
diff --git a/layouts/shortcodes/circle.html b/layouts/shortcodes/circle.html
index 101a8688..d055c515 100644
--- a/layouts/shortcodes/circle.html
+++ b/layouts/shortcodes/circle.html
@@ -1,21 +1,31 @@
{{ $src := .Get "src" }}
{{ $alt := .Get "alt" }}
-{{ $image := resources.Get $src }}
-{{ $small := $image }}
-{{ $medium := $image }}
-{{ $large := $image }}
-{{ if hugo.IsExtended }}
- {{ $small = $image.Resize "480x webp" }}
- {{ $medium = $image.Resize "768x webp" }}
- {{ $large = $image.Resize "1024x webp" }}
-{{ else }}
- {{ $small = $image.Resize "480x jpg" }}
- {{ $medium = $image.Resize "768x jpg" }}
- {{ $large = $image.Resize "1024x jpg" }}
+{{ $imageSrc := $src }}
+{{ $hashedDestination := sha256 $imageSrc }}
+{{ $extension := path.Ext $imageSrc }}
+{{ $localPath := delimit (slice "images/" $hashedDestination $extension) "" }}
+{{ $assetPath := delimit (slice "assets/" $localPath) "" }}
+{{ $imagePath := $imageSrc }}
+{{ if (fileExists $assetPath) }}
+ {{ $imagePath = $localPath }}
{{ end }}
-<br>
+{{ with resources.Get $imagePath }}
+ {{ $image := . }}
+ {{ $small := $image }}
+ {{ $medium := $image }}
+ {{ $large := $image }}
+ {{ if hugo.IsExtended }}
+ {{ $small = $image.Resize "480x webp" }}
+ {{ $medium = $image.Resize "768x webp" }}
+ {{ $large = $image.Resize "1024x webp" }}
+ {{ else }}
+ {{ $small = $image.Resize "480x jpg" }}
+ {{ $medium = $image.Resize "768x jpg" }}
+ {{ $large = $image.Resize "1024x jpg" }}
+ {{ end }}
+ <br>
<figure class="image is-180x180 container">
<picture>
<source media="(max-width: 480px)" srcset="{{ $small.RelPermalink }} 480w">
@@ -30,4 +40,17 @@
/>
</picture>
</figure>
-<br>
+ <br>
+{{ else }}
+ <br>
+ <figure class="image is-180x180 container">
+ <img
+ class="is-rounded"
+ src="{{ $imagePath }}"
+ alt="{{ $alt | safeHTML }}"
+ decoding="async"
+ loading="lazy"
+ />
+ </figure>
+ <br>
+{{ end }}