improve image handling; add imgtitle page param

This commit is contained in:
Helmut Merz 2022-10-13 14:21:09 +02:00
parent d66c8afe0d
commit 4a9e6d9faa
2 changed files with 19 additions and 8 deletions

View file

@ -12,18 +12,23 @@
{{- $img = $refImg -}}
{{- end -}}
{{ if $img -}}
{{- $image := (resources.Get (printf "img/%s" $img)).Resize "400x" -}}
{{- $image := resources.Get (printf "img/%s" $img) -}}
{{- if eq $image nil -}}
{{- warnf "not found: %v" $img -}}
{{- else -}}
{{- $image = $image.Resize "400x" -}}
<img width="100%"
src="{{ $image.RelPermalink }}" alt="{{ .Title }}">
{{ else if .Params.teaser }}
{{- end -}}
{{- else if .Params.teaser -}}
<div class="card-header">
<p class="card-text">{{ .Params.teaser }}</p>
</div>
{{ else if .Site.Params.defaultImage }}
{{- else if .Site.Params.defaultImage -}}
<img width="100%"
src="{{ .Site.BaseURL }}img/{{ .Site.Params.defaultImage }}"
alt="{{ .Site.Title }}">
{{ end }}
{{- end }}
<div class="card-body">
<span class="card-title h4">{{ .Title | truncate 30 }}</span>

View file

@ -18,10 +18,16 @@
{{- if $refPage -}}
<a href="{{ $refPage.Permalink }}"><img
width="100%" class="mt-3"
src="{{ $image.RelPermalink }}" alt="{{ $refPage.Title }}"></a>
src="{{ $image.RelPermalink }}"
alt="{{ $refPage.Title }}"
title="{{ $refPage.Title }}"></a>
{{- else -}}
<img width="100%" class="mt-3"
src="{{ $image.RelPermalink }}" alt="{{ .Title }}">
src="{{ $image.RelPermalink }}"
alt="{{ .Title }}"
{{- if .Params.imgtitle -}}
title="{{ .Params.imgtitle }}"
{{- end -}}>
{{- end -}}
{{- else if .Params.teaser -}}
<div class="card mt-3">