Skip to content

Commit

Permalink
fix: skip image process on svgs and remote images (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
jzerfowski authored Jan 18, 2025
1 parent a933f46 commit a1232ec
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions layouts/shortcodes/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@
{{- $options := .Get "options" | default "800x webp q80" -}}
{{- $process := .Get "process" | default (printf "%s %s" $method $options) -}}

{{- with or (.Page.Resources.Get $image) (resources.Get $image) -}}
{{/* Retrieve the $image resource from local or global resources */}}
{{- $processed := .Process $process -}}
{{- $width = $processed.Width -}}
{{- $height = $processed.Height -}}
{{- $image = $processed.RelPermalink -}}
{{ else }}
{{/* Otherwise, use relative link of the image */}}
{{- if hasPrefix $image "/" -}}
{{- $image = relURL (strings.TrimPrefix "/" $image) -}}
{{- if and $image (not (urls.Parse $image).Scheme) -}}
{{- with or (.Page.Resources.Get $image) (resources.Get $image) -}}
{{/* .Process does not work on svgs */}}
{{- if (not (eq .MediaType.SubType "svg")) -}}
{{/* Retrieve the $image resource from local or global resources */}}
{{- $processed := .Process $process -}}
{{- $width = $processed.Width -}}
{{- $height = $processed.Height -}}
{{- $image = $processed.RelPermalink -}}
{{- end -}}
{{ else }}
{{/* Otherwise, use relative link of the image */}}
{{- if hasPrefix $image "/" -}}
{{- $image = relURL (strings.TrimPrefix "/" $image) -}}
{{- end -}}
{{- end -}}
{{- end -}}

Expand Down

0 comments on commit a1232ec

Please sign in to comment.