page resources are returned in reverse, so get the last image rather than the first

This commit is contained in:
rra 2024-11-24 12:03:07 +01:00
parent 856ff9851e
commit a722904938

View File

@ -19,7 +19,8 @@
</div> </div>
{{end}} {{end}}
{{ else if (.Resources.ByType "image") }} {{ else if (.Resources.ByType "image") }}
{{ with (index (.Resources.ByType "image") 0) }} {{/* Somehow the image resources are iterated in reverse, so we need to get the last one*/}}
{{ range last 1 (.Resources.ByType "image") }}
{{ $img := . }} {{ $img := . }}
{{ $height := add .Height 0.0}} {{ $height := add .Height 0.0}}
{{ $ratio := div $height .Width}} {{ $ratio := div $height .Width}}