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

github.com/chipzoller/hugo-clarity.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Boothe <git@rootwork.org>2022-05-11 23:45:38 +0300
committerIvan Boothe <git@rootwork.org>2022-05-11 23:45:38 +0300
commit831c538e934e2de2138036c2f941d27e99f2ab26 (patch)
treecfaccc6f21e6e42b241c0c96a5e7dd25a4aced62 /layouts
parent59a19ba5e6ea90f69d7282a169782ce7531c5929 (diff)
restore modern image replacementimage-handling-improvements
Signed-off-by: Ivan Boothe <git@rootwork.org>
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/_markup/render-image.html3
-rw-r--r--layouts/partials/figure.html20
-rw-r--r--layouts/partials/image.html3
3 files changed, 16 insertions, 10 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html
index 48acc6f..9826273 100644
--- a/layouts/_default/_markup/render-image.html
+++ b/layouts/_default/_markup/render-image.html
@@ -45,7 +45,8 @@
dict
"file" $file
"image" $image
- "dir" $.Page.RelPermalink
+ "diskPath" $.Page.File.Dir
+ "webPath" $.Page.RelPermalink
"alt" $alt
"cap" $cap
"classes" ($scratch.Get "classes")
diff --git a/layouts/partials/figure.html b/layouts/partials/figure.html
index 0aea160..4a0f7b1 100644
--- a/layouts/partials/figure.html
+++ b/layouts/partials/figure.html
@@ -11,17 +11,19 @@
{{- $file := .file -}}
{{- $image := .image -}}
-{{- $dir := .dir -}}
+{{- $diskPath := .diskPath -}}
+{{- $webPath := .webPath -}}
{{- $alt := .alt -}}
{{- $cap := .cap -}}
{{- $classes := .classes -}}
{{- $bundle := .bundle -}}
+{{- $fileWeb := .file -}}
{{- if eq $bundle true -}}
- {{ $file = path.Join $dir $file }}
+ {{ $fileWeb = path.Join $webPath $file }}
{{ if in $classes "image_svg" }}
- {{ if strings.HasPrefix .file "http" }}
- {{ $file = .file }}
+ {{ if strings.HasPrefix $file "http" }}
+ {{ $fileWeb = $file }}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -34,9 +36,11 @@
{{ $name := replace $file (path.Ext $file) "" }}
{{ $ext := slice "avif" "webp" "jxl" }}
{{- range $ext -}}
- {{ $path := printf "%s" . | printf "%s%s" "." | printf "%s%s" $name | printf "%s" }}
- {{- if fileExists $path -}}
- <source srcset="{{ $path }}" type="image/{{ . }}">
+ {{ $item := printf "%s" . | printf "%s%s" "." | printf "%s%s" $name | printf "%s" }}
+ {{ $itemDisk := path.Join $diskPath $item }}
+ {{ $itemWeb := path.Join $webPath $item }}
+ {{- if fileExists $itemDisk -}}
+ <source srcset="{{ $itemWeb }}" type="image/{{ . }}">
{{- end -}}
{{- end -}}
{{- end -}}
@@ -53,7 +57,7 @@
src="{{ .RelPermalink }}"
{{ else }}
class="{{ $classes }} image_unprocessed"
- src="{{ $file }}"
+ src="{{ $fileWeb }}"
{{ end }}
{{ with $cap }}
title="{{ htmlEscape $cap }}"
diff --git a/layouts/partials/image.html b/layouts/partials/image.html
index 2f7b4ef..dac1d64 100644
--- a/layouts/partials/image.html
+++ b/layouts/partials/image.html
@@ -51,7 +51,8 @@
dict
"file" $file
"image" $image
- "dir" $.Page.RelPermalink
+ "diskPath" $.Page.File.Dir
+ "webPath" $.Page.RelPermalink
"alt" $alt
"cap" $cap
"classes" ($scratch.Get "classes")