From aeb7c88949a451cd71adf3071477f743cf4f5187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asger=20Geel=20Weirs=C3=B8e?= Date: Sun, 1 Nov 2026 16:47:08 +0100 Subject: [PATCH] fix: billeder i udkast og preview uden sitemap-link MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Zola gør relative billedstier absolutte, så omskrivningen til webp skal matche den form. Ikke-konverterbare billeder får en rod-relativ sti, som preview kan flytte. Co-Authored-By: Claude Opus 5.5 --- templates/base.html | 2 ++ templates/indlaeg.html | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/templates/base.html b/templates/base.html index f34979f..66511ef 100644 --- a/templates/base.html +++ b/templates/base.html @@ -77,7 +77,9 @@ +{%- if not preview %} +{%- endif %} diff --git a/templates/indlaeg.html b/templates/indlaeg.html index c4f8f58..19b8fad 100644 --- a/templates/indlaeg.html +++ b/templates/indlaeg.html @@ -24,10 +24,13 @@ {#- Billeder i bundlen serveres som webp; markdown bruger bare ![tekst](fil.png). -#} {%- set indhold = page.content %} {%- for a in page.assets %} - {%- if a is ending_with(pat=".png") or a is ending_with(pat=".jpg") or a is ending_with(pat=".jpeg") or a is ending_with(pat=".webp") or a is ending_with(pat=".avif") %} {%- set fil = a | split(pat="/") | last %} + {%- set fra = 'src="' ~ config.base_url ~ page.path ~ fil ~ '"' %} + {%- if fil is ending_with(pat=".png") or fil is ending_with(pat=".jpg") or fil is ending_with(pat=".jpeg") or fil is ending_with(pat=".webp") %} {%- set b = resize_image(path="blog/" ~ page.slug ~ "/" ~ fil, width=1200, height=10000, op="fit", format="webp", quality=80) %} - {%- set_global indhold = indhold | replace(from='src="' ~ fil ~ '"', to='src="' ~ (b.url | replace(from=config.base_url, to="")) ~ '" width="' ~ b.width ~ '" height="' ~ b.height ~ '" loading="lazy" decoding="async"') %} + {%- set_global indhold = indhold | replace(from=fra, to='src="' ~ (b.url | replace(from=config.base_url, to="")) ~ '" width="' ~ b.width ~ '" height="' ~ b.height ~ '" loading="lazy" decoding="async"') %} + {%- else %} + {%- set_global indhold = indhold | replace(from=fra, to='src="' ~ page.path ~ fil ~ '"') %} {%- endif %} {%- endfor %}
{{ indhold | safe }}