feat: add support for imagePosition config

This commit is contained in:
ZhenShuo Leo
2025-09-30 23:09:43 +08:00
parent 22f097f92a
commit f827f8e8d8
7 changed files with 74 additions and 8 deletions
+10 -1
View File
@@ -1,5 +1,6 @@
{{ $disableImageOptimization := site.Store.Get "disableImageOptimization" }}
{{ $useDefault := false }}
{{ $featured := "" }}
{{ $featuredURL := "" }}
{{ with .Params.featureimage }}
@@ -25,8 +26,10 @@
{{ $default := site.Store.Get "defaultBackgroundImage" }}
{{ if $default.url }}
{{ $featuredURL = $default.url }}
{{ $useDefault = true }}
{{ else if $default.obj }}
{{ $featured = $default.obj }}
{{ $useDefault = true }}
{{ end }}
{{ end }}
@@ -42,6 +45,11 @@
{{ end }}
{{ with $featuredURL }}
{{ $style := "" }}
{{ $defaultPosition := cond $useDefault site.Params.imagePosition false }}
{{ with $.Params.imagePosition | default $defaultPosition }}
{{ $style = printf "object-position: %s;" . }}
{{ end }}
<div class="overflow-hidden h-36 md:h-56 lg:h-72">
<img
src="{{ . }}"
@@ -49,6 +57,7 @@
loading="eager"
decoding="async"
fetchpriority="high"
class="w-full h-full nozoom object-cover">
class="w-full h-full nozoom object-cover"
{{ if $style }}style="{{ $style | safeCSS }}"{{ end }}>
</div>
{{ end }}