mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
image: get resource images if link is prefixed with ./ #747
This commit is contained in:
parent
e95386a556
commit
8b9631705d
1 changed files with 6 additions and 1 deletions
|
@ -17,7 +17,7 @@
|
||||||
{{- $width := "auto" }}
|
{{- $width := "auto" }}
|
||||||
{{- $dest_url := urls.Parse $url }}
|
{{- $dest_url := urls.Parse $url }}
|
||||||
{{- $dest_path := $dest_url.Path }}
|
{{- $dest_path := $dest_url.Path }}
|
||||||
{{- $image := $page.Resources.GetMatch $dest_path }}
|
{{- $image := $page.Resources.GetMatch (path.Clean $dest_url.Path) }}
|
||||||
{{- if not $image }}
|
{{- if not $image }}
|
||||||
{{- $image = .Resources.GetMatch $dest_path }}
|
{{- $image = .Resources.GetMatch $dest_path }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@ -30,6 +30,11 @@
|
||||||
{{- $url = printf "%s?%s" $url $dest_url.RawQuery }}
|
{{- $url = printf "%s?%s" $url $dest_url.RawQuery }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if not $image }}
|
||||||
|
{{- if and ($page.Site.Params.render_hooks.errorlevel "warning") (not (or (strings.HasPrefix .url "http://") (strings.HasPrefix .url "https://") )) }}
|
||||||
|
{{- warnf "%q: Image %s is not a resource but linked anyways." $page.File.Filename .url }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
{{- if $dest_url.RawQuery }}
|
{{- if $dest_url.RawQuery }}
|
||||||
{{- if $dest_url.Query.Has "classes" }}
|
{{- if $dest_url.Query.Has "classes" }}
|
||||||
{{- $classes := slice | append (split ($dest_url.Query.Get "classes") ",") }}
|
{{- $classes := slice | append (split ($dest_url.Query.Get "classes") ",") }}
|
||||||
|
|
Loading…
Reference in a new issue