Change figure shortcode to use relative paths as page resources
This commit is contained in:
@@ -3,7 +3,14 @@
|
||||
{{ with $link }}
|
||||
<a href="{{ . }}">
|
||||
{{ end }}
|
||||
<img{{ with (.Get 4 | default (.Get `alt`)) }} alt="{{ . }}"{{ end }} class="figure-img img-fluid"{{ with .Get `height` }} height="{{ . }}"{{ end }} src="{{ .Get 0 | default (.Get `src`) }}"{{ with (.Get 3 | default (.Get `title`)) }} title="{{ . }}"{{ end }}{{ with .Get `width` }} width="{{ . }}"{{ end }}>
|
||||
{{ $src := .Get 0 | default (.Get `src`) }}
|
||||
{{ $url := urls.Parse $src }}
|
||||
{{ if and (not $url.IsAbs) (not (hasPrefix $url.Path "/")) }}
|
||||
{{ with .Page.Resources.GetMatch $src }}
|
||||
{{ $src = .RelPermalink }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<img{{ with (.Get 4 | default (.Get `alt`)) }} alt="{{ . }}"{{ end }} class="figure-img img-fluid"{{ with .Get `height` }} height="{{ . }}"{{ end }} src="{{ $src }}"{{ with (.Get 3 | default (.Get `title`)) }} title="{{ . }}"{{ end }}{{ with .Get `width` }} width="{{ . }}"{{ end }}>
|
||||
{{ if $link }}
|
||||
</a>
|
||||
{{ end }}
|
||||
|
Reference in New Issue
Block a user