7
0
Fork 0

Toevoegen van webp-alternatief inclusief dynamic bepalen van afmetingen

This commit is contained in:
Michael Boelen 2023-06-19 10:20:38 +02:00
parent 627346d466
commit 448c430db3
4 changed files with 6 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View file

@ -4,6 +4,8 @@
<header> <header>
<div class="header-content"> <div class="header-content">
<!-- Logo wordt nu benoemd als URL, dus we strippen de eerste slash, vervolgens halen we deze uit de assets directory -->
<!-- Logo staat zowel in assets als static, zodat deze gekopieerd worden. Dit is een TODO om te ontdubbelen -->
{{ $logoresource := resources.Get (.Site.Params.logoNormal | replaceRE "^/" "") }} {{ $logoresource := resources.Get (.Site.Params.logoNormal | replaceRE "^/" "") }}
<a class="logo" href="{{ "/" | relLangURL }}" title="{{ strings.FirstUpper (i18n "back_to_home") }}"> <a class="logo" href="{{ "/" | relLangURL }}" title="{{ strings.FirstUpper (i18n "back_to_home") }}">
@ -14,19 +16,19 @@
{{ if ($isJPG) -}} {{ if ($isJPG) -}}
{{ $webpPath:= replace $logoresource ".jpg" ".webp" }} {{ $webpPath:= replace $logoresource ".jpg" ".webp" }}
{{ $webpPathStatic:= printf "%s" $webpPath }} {{ $webpPathStatic:= printf "assets/%s" $webpPath }}
{{ if (fileExists $webpPathStatic) -}} {{ if (fileExists $webpPathStatic) -}}
<source srcset="{{ $webpPath | safeURL }}" type="image/webp"> <source srcset="/{{ $webpPath | safeURL }}" type="image/webp">
{{- end }} {{- end }}
{{- end }} {{- end }}
{{ if ($isPNG) -}} {{ if ($isPNG) -}}
{{ $webpPath:= replace $logoresource ".png" ".webp" }} {{ $webpPath:= replace $logoresource ".png" ".webp" }}
{{ $webpPathStatic:= printf "%s" $webpPath }} {{ $webpPathStatic:= printf "assets/%s" $webpPath }}
{{ if (fileExists $webpPathStatic) -}} {{ if (fileExists $webpPathStatic) -}}
<source srcset="{{ $webpPath | safeURL }}" type="image/webp"> <source srcset="/{{ $webpPath | safeURL }}" type="image/webp">
{{- end }} {{- end }}
{{- end }} {{- end }}