improve image handling; add imgtitle page param
This commit is contained in:
parent
d66c8afe0d
commit
4a9e6d9faa
2 changed files with 19 additions and 8 deletions
|
@ -12,18 +12,23 @@
|
||||||
{{- $img = $refImg -}}
|
{{- $img = $refImg -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{ if $img -}}
|
{{ 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%"
|
<img width="100%"
|
||||||
src="{{ $image.RelPermalink }}" alt="{{ .Title }}">
|
src="{{ $image.RelPermalink }}" alt="{{ .Title }}">
|
||||||
{{ else if .Params.teaser }}
|
{{- end -}}
|
||||||
|
{{- else if .Params.teaser -}}
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<p class="card-text">{{ .Params.teaser }}</p>
|
<p class="card-text">{{ .Params.teaser }}</p>
|
||||||
</div>
|
</div>
|
||||||
{{ else if .Site.Params.defaultImage }}
|
{{- else if .Site.Params.defaultImage -}}
|
||||||
<img width="100%"
|
<img width="100%"
|
||||||
src="{{ .Site.BaseURL }}img/{{ .Site.Params.defaultImage }}"
|
src="{{ .Site.BaseURL }}img/{{ .Site.Params.defaultImage }}"
|
||||||
alt="{{ .Site.Title }}">
|
alt="{{ .Site.Title }}">
|
||||||
{{ end }}
|
{{- end }}
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<span class="card-title h4">{{ .Title | truncate 30 }}</span>
|
<span class="card-title h4">{{ .Title | truncate 30 }}</span>
|
||||||
|
|
|
@ -18,10 +18,16 @@
|
||||||
{{- if $refPage -}}
|
{{- if $refPage -}}
|
||||||
<a href="{{ $refPage.Permalink }}"><img
|
<a href="{{ $refPage.Permalink }}"><img
|
||||||
width="100%" class="mt-3"
|
width="100%" class="mt-3"
|
||||||
src="{{ $image.RelPermalink }}" alt="{{ $refPage.Title }}"></a>
|
src="{{ $image.RelPermalink }}"
|
||||||
|
alt="{{ $refPage.Title }}"
|
||||||
|
title="{{ $refPage.Title }}"></a>
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
<img width="100%" class="mt-3"
|
<img width="100%" class="mt-3"
|
||||||
src="{{ $image.RelPermalink }}" alt="{{ .Title }}">
|
src="{{ $image.RelPermalink }}"
|
||||||
|
alt="{{ .Title }}"
|
||||||
|
{{- if .Params.imgtitle -}}
|
||||||
|
title="{{ .Params.imgtitle }}"
|
||||||
|
{{- end -}}>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- else if .Params.teaser -}}
|
{{- else if .Params.teaser -}}
|
||||||
<div class="card mt-3">
|
<div class="card mt-3">
|
||||||
|
|
Loading…
Add table
Reference in a new issue