diff options
author | Ivan Boothe <git@rootwork.org> | 2022-05-17 02:50:18 +0300 |
---|---|---|
committer | Ivan Boothe <git@rootwork.org> | 2022-05-17 02:50:18 +0300 |
commit | 9c6e83697a84f3075be51057e2d1468709f650fd (patch) | |
tree | 64de650ed4367f3582dfd53e452814832c1505c0 | |
parent | 616b44986438752406ac579e620e35b1bab1cd50 (diff) |
Handle non-image resources
Signed-off-by: Ivan Boothe <git@rootwork.org>
-rw-r--r-- | layouts/_default/_markup/render-image.html | 16 | ||||
-rw-r--r-- | layouts/partials/image.html | 16 |
2 files changed, 20 insertions, 12 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 9826273..03c1802 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -18,13 +18,17 @@ {{- 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.MediaType.MainType }} + {{- 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 = "" -}} diff --git a/layouts/partials/image.html b/layouts/partials/image.html index dac1d64..fbd8003 100644 --- a/layouts/partials/image.html +++ b/layouts/partials/image.html @@ -28,13 +28,17 @@ {{- 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.MediaType.MainType }} + {{- 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 = "" -}} |