diff options
Diffstat (limited to 'layouts/_default/_markup/render-image.html')
| -rw-r--r-- | layouts/_default/_markup/render-image.html | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 0fc039c..c4d7497 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,20 +1,26 @@ -{{- $img := .Page.Resources.GetMatch .Destination -}} -{{- if and (not $img) .Page.File -}} - {{ $path := path.Join .Page.File.Dir .Destination }} - {{- $img = resources.Get $path -}} -{{- end -}} +{{- $url := urls.Parse .Destination -}} +{{- if $url.Scheme -}} + {{/* third party image */}} + <img loading="lazy" src="{{ .Destination | safeURL }}" alt="{{ $.Text }}" {{ with $.Title}} title="{{ . }}" {{ end }} /> +{{- else -}} + {{/* internal image */}} + {{- $img := .Page.Resources.GetMatch .Destination -}} + {{- if not $img -}} + {{- $img = resources.Get .Destination -}} + {{- end -}} -{{- if $img -}} - {{- if eq $img.MediaType.MainType "video" -}} - <figure> - <video class="video-shortcode" preload="metadata" controls> - <source src="{{ $img.RelPermalink }}"> - There should have been a video here but your browser does not seem to support it. - </video> - </figure> + {{- if $img -}} + {{- if eq $img.MediaType.MainType "video" -}} + <figure> + <video class="video-shortcode" preload="metadata" controls> + <source src="{{ $img.RelPermalink }}"> + There should have been a video here but your browser does not seem to support it. + </video> + </figure> + {{- else -}} + <img loading="lazy" src="{{ $img.RelPermalink }}" type="" alt="{{ $.Text }}" {{ with $.Title}} title="{{ . }}" {{ end }} /> + {{- end -}} {{- else -}} - <img loading="lazy" src="{{ $img.RelPermalink }}" type="" alt="{{ $.Text }}" {{ with $.Title}} title="{{ . }}" {{ end }} /> + {{- warnf "No image found for %s from %s" .Destination .Page.File }} {{- end -}} -{{- else -}} - {{- warnf "No image found for %s from %s" .Destination .Page.File }} {{- end -}} |
