Skip to content

Commit f95cdb6

Browse files
committed
Skip .Process on svgs and Remote images
1 parent a933f46 commit f95cdb6

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

layouts/shortcodes/card.html

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@
1515
{{- $options := .Get "options" | default "800x webp q80" -}}
1616
{{- $process := .Get "process" | default (printf "%s %s" $method $options) -}}
1717

18-
{{- with or (.Page.Resources.Get $image) (resources.Get $image) -}}
19-
{{/* Retrieve the $image resource from local or global resources */}}
20-
{{- $processed := .Process $process -}}
21-
{{- $width = $processed.Width -}}
22-
{{- $height = $processed.Height -}}
23-
{{- $image = $processed.RelPermalink -}}
24-
{{ else }}
25-
{{/* Otherwise, use relative link of the image */}}
26-
{{- if hasPrefix $image "/" -}}
27-
{{- $image = relURL (strings.TrimPrefix "/" $image) -}}
18+
{{- if and $image (not (urls.Parse $image).Scheme) -}}
19+
{{- with or (.Page.Resources.Get $image) (resources.Get $image) -}}
20+
{{/* .Process does not work on svgs */}}
21+
{{- if (not (eq .MediaType.SubType "svg")) -}}
22+
{{/* Retrieve the $image resource from local or global resources */}}
23+
{{- $processed := .Process $process -}}
24+
{{- $width = $processed.Width -}}
25+
{{- $height = $processed.Height -}}
26+
{{- $image = $processed.RelPermalink -}}
27+
{{- end -}}
28+
{{ else }}
29+
{{/* Otherwise, use relative link of the image */}}
30+
{{- if hasPrefix $image "/" -}}
31+
{{- $image = relURL (strings.TrimPrefix "/" $image) -}}
32+
{{- end -}}
2833
{{- end -}}
2934
{{- end -}}
3035

0 commit comments

Comments
 (0)