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 01:07:44 +0300
committerIvan Boothe <git@rootwork.org>2022-05-11 01:07:44 +0300
commit3a5ad329424b23f7b0e4326cc8c3ae4cbefbdff1 (patch)
treef3cd132b506299c33c68b39fe1c5bb86c5080891
parentc8261289c2dab76d0e810cf499d240d145479aaf (diff)
add (non-)support for SVG image processing
Signed-off-by: Ivan Boothe <git@rootwork.org>
-rw-r--r--layouts/_default/_markup/render-image.html11
-rw-r--r--layouts/partials/figure.html5
-rw-r--r--layouts/partials/image.html11
3 files changed, 23 insertions, 4 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html
index a96b4e6..8be264c 100644
--- a/layouts/_default/_markup/render-image.html
+++ b/layouts/_default/_markup/render-image.html
@@ -18,8 +18,15 @@
{{- if strings.HasPrefix $file "http" -}}
{{- $scratch.Add "classes" " image_external" -}}
{{- $image = resources.GetRemote $file -}}
- {{- $file = path.Join "images" $image -}}
- {{- $image = $image.Content | resources.FromString $file -}}
+ {{- 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 -}}
+ {{- end -}}
{{- else -}}
{{- $scratch.Add "classes" " image_internal" -}}
{{ $file = (path.Clean $file) }}
diff --git a/layouts/partials/figure.html b/layouts/partials/figure.html
index 5630bc5..d9f6b0a 100644
--- a/layouts/partials/figure.html
+++ b/layouts/partials/figure.html
@@ -19,6 +19,11 @@
{{- if eq $bundle true -}}
{{ $file = path.Join $dir $file }}
+ {{ if in $classes "image_svg" }}
+ {{ if strings.HasPrefix .file "http" }}
+ {{ $file = .file }}
+ {{- end -}}
+ {{- end -}}
{{- end -}}
<figure>
diff --git a/layouts/partials/image.html b/layouts/partials/image.html
index 2e67941..b7228fa 100644
--- a/layouts/partials/image.html
+++ b/layouts/partials/image.html
@@ -28,8 +28,15 @@
{{- if strings.HasPrefix $file "http" -}}
{{- $scratch.Add "classes" " image_external" -}}
{{- $image = resources.GetRemote $file -}}
- {{- $file = path.Join "images" $image -}}
- {{- $image = $image.Content | resources.FromString $file -}}
+ {{- 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 -}}
+ {{- end -}}
{{- else -}}
{{- $scratch.Add "classes" " image_internal" -}}
{{ $file = (path.Join "/" $file) }}