From 79e21d606a04274c716c129af690deffba996843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sat, 19 Nov 2022 00:23:02 +0100 Subject: [PATCH] Revert "theme: optimize image loading #393" This reverts commit c7f6cbf71bf58ed655e949dd66d38aedff8728c1. --- layouts/partials/shortcodes/image.html | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/layouts/partials/shortcodes/image.html b/layouts/partials/shortcodes/image.html index 5118419535..81fc264709 100644 --- a/layouts/partials/shortcodes/image.html +++ b/layouts/partials/shortcodes/image.html @@ -7,19 +7,13 @@ {{- $height := "auto" }} {{- $width := "auto" }} {{- $dest_url := urls.Parse $url }} -{{- $dest_path := path.Clean $dest_url.Path }} -{{- $image := "" }} -{{- if ($dest_url.IsAbs) }} - {{/* this image does not belong to the site, get it from external */}} - {{- $image = resources.GetRemote $url }} -{{- else }} - {{- /* Get local page resource image. */}} - {{- $image = $context.Resources.Get $dest_path }} - {{- if not $image }} - {{- /* Get local image from assets directory. */}} - {{- $dest_path := path.Clean $dest_url.Path }} - {{- $image = resources.Get $dest_path }} - {{- end }} +{{- $dest_path := $dest_url.Path }} +{{- $image := $context.Resources.GetMatch $dest_path }} +{{- if not $image }} + {{- $image = .Resources.GetMatch $dest_path }} +{{- end }} +{{- if not $image }} + {{- $image = .Resources.GetRemote $url }} {{- end }} {{- if $image }} {{- $url = $image.RelPermalink }} @@ -32,7 +26,7 @@ {{- end }} {{- end }} {{- if $dest_url.RawQuery }} - {{- $classes = delimit (split ($dest_url.Query.Get "classes") ",") " " }} + {{- $classes = (replaceRE "\\s+" " " (replaceRE "," " " ($dest_url.Query.Get "classes") ) ) }} {{- $featherlight = (ne ($dest_url.Query.Get "featherlight") "false") }} {{- if or ($dest_url.Query.Get "height") ($dest_url.Query.Get "width") }} {{- $height = "auto" }}