diff options
author | Shohei Ueda <30958501+peaceiris@users.noreply.github.com> | 2021-06-13 11:41:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-13 11:41:00 +0300 |
commit | 0d5ba91a93fbeb7eb70247db1f7d27ae28bfe3cf (patch) | |
tree | 1b4d5b501a682a66cedd21383a3952ce78496bf8 /layouts | |
parent | 1379bb6e5267bbeaa33e4c646cf690c026d26c91 (diff) |
fix: gitignore rule (#369)
* fix: fetched image handling
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/_markup/render-image.html | 10 | ||||
-rw-r--r-- | layouts/partials/eyecatch.html | 9 | ||||
-rw-r--r-- | layouts/shortcodes/circle.html | 51 |
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 }} |