From 3a5ad329424b23f7b0e4326cc8c3ae4cbefbdff1 Mon Sep 17 00:00:00 2001 From: Ivan Boothe Date: Tue, 10 May 2022 15:07:44 -0700 Subject: add (non-)support for SVG image processing Signed-off-by: Ivan Boothe --- layouts/_default/_markup/render-image.html | 11 +++++++++-- layouts/partials/figure.html | 5 +++++ layouts/partials/image.html | 11 +++++++++-- 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 -}}
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) }} -- cgit v1.2.3