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-19 00:18:53 +0300
committerGitHub <noreply@github.com>2022-05-19 00:18:53 +0300
commitacf64ead4f1eb25da44c284bf7ed4f83c65c2d2f (patch)
tree671a9e4611d6297b3e529ba4c2ab35234af88ab8
parent616b44986438752406ac579e620e35b1bab1cd50 (diff)
parent15debdd534aaa6521e87e93d93c76b228e9958ee (diff)
Merge pull request #305 from chipzoller/handle-non-image-resources
-rw-r--r--layouts/_default/_markup/render-image.html18
-rw-r--r--layouts/partials/image.html18
2 files changed, 20 insertions, 16 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html
index 9826273..5ca7332 100644
--- a/layouts/_default/_markup/render-image.html
+++ b/layouts/_default/_markup/render-image.html
@@ -18,16 +18,18 @@
{{- if strings.HasPrefix $file "http" -}}
{{- $scratch.Add "classes" " image_external" -}}
{{- $image = resources.GetRemote $file -}}
- {{- if eq $image.MediaType.MainType "image" -}}
- {{- if eq $image.MediaType.SubType "svg" -}}
- {{- $image = "" -}}
- {{- $scratch.Add "classes" " image_svg" -}}
+ {{- with $image }}
+ {{- if eq $image.MediaType.MainType "image" -}}
+ {{- if eq $image.MediaType.SubType "svg" -}}
+ {{- $image = "" -}}
+ {{- $scratch.Add "classes" " image_svg" -}}
+ {{- else -}}
+ {{- $file = path.Join "images" $image -}}
+ {{- $image = $image.Content | resources.FromString $file -}}
+ {{- end -}}
{{- else -}}
- {{- $file = path.Join "images" $image -}}
- {{- $image = $image.Content | resources.FromString $file -}}
+ {{- $image = "" -}}
{{- end -}}
- {{- else -}}
- {{- $image = "" -}}
{{- end -}}
{{- else -}}
{{- $scratch.Add "classes" " image_internal" -}}
diff --git a/layouts/partials/image.html b/layouts/partials/image.html
index dac1d64..c9b9662 100644
--- a/layouts/partials/image.html
+++ b/layouts/partials/image.html
@@ -28,16 +28,18 @@
{{- if strings.HasPrefix $file "http" -}}
{{- $scratch.Add "classes" " image_external" -}}
{{- $image = resources.GetRemote $file -}}
- {{- if eq $image.MediaType.MainType "image" -}}
- {{- if eq $image.MediaType.SubType "svg" -}}
- {{- $image = "" -}}
- {{- $scratch.Add "classes" " image_svg" -}}
+ {{- with $image }}
+ {{- if eq $image.MediaType.MainType "image" -}}
+ {{- if eq $image.MediaType.SubType "svg" -}}
+ {{- $image = "" -}}
+ {{- $scratch.Add "classes" " image_svg" -}}
+ {{- else -}}
+ {{- $file = path.Join "images" $image -}}
+ {{- $image = $image.Content | resources.FromString $file -}}
+ {{- end -}}
{{- else -}}
- {{- $file = path.Join "images" $image -}}
- {{- $image = $image.Content | resources.FromString $file -}}
+ {{- $image = "" -}}
{{- end -}}
- {{- else -}}
- {{- $image = "" -}}
{{- end -}}
{{- else -}}
{{- $scratch.Add "classes" " image_internal" -}}