Skip to content

Commit

Permalink
link: backout #777
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Feb 22, 2024
1 parent 3333a41 commit 4e5fe8d
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions layouts/partials/shortcodes/image.html
Expand Up @@ -17,22 +17,24 @@
{{- $width := "auto" }}
{{- $dest_url := urls.Parse $url }}
{{- $dest_path := $dest_url.Path }}
{{- $image := "" }}
{{- if not $dest_url.IsAbs }}
{{- with or ($page.Resources.Get $dest_url.Path) (resources.Get $dest_url.Path) }}
{{- $image = . }}
{{- $image := $page.Resources.GetMatch (path.Clean $dest_url.Path) }}
{{- if not $image }}
{{- $image = .Resources.GetMatch $dest_path }}
{{- end }}
{{- if not $image }}
{{- $image = .Resources.GetRemote $url }}
{{- end }}
{{- if $image }}
{{- $url = $image.RelPermalink }}
{{- if $dest_url.RawQuery }}
{{- $url = printf "%s?%s" $url $dest_url.RawQuery }}
{{- end }}
{{- with $image }}
{{- $url = $image.RelPermalink }}
{{- with $dest_url.RawQuery }}
{{- $url = printf "%s?%s" $url . }}
{{- end }}
{{- else }}
{{- if eq $page.Site.Params.image.errorlevel "warning" }}
{{- warnf "%q: image '%s' is not a resource but linked anyways" $page.File.Filename .url }}
{{- else if eq $page.Site.Params.image.errorlevel "error" }}
{{- errorf "%q: image '%s' is not a resource" $page.File.Filename .url }}
{{- end }}
{{- end }}
{{- if and (not $image) (not $dest_url.IsAbs) }}
{{- if eq $page.Site.Params.image.errorlevel "warning" }}
{{- warnf "%q: image '%s' is not a resource but linked anyways" $page.File.Filename .url }}
{{- else if eq $page.Site.Params.image.errorlevel "error" }}
{{- errorf "%q: image '%s' is not a resource" $page.File.Filename .url }}
{{- end }}
{{- end }}
{{- if $dest_url.RawQuery }}
Expand Down

0 comments on commit 4e5fe8d

Please sign in to comment.