resize card images on the fly; optionally link to image reference page
This commit is contained in:
parent
e3e6b739df
commit
f3d9139033
2 changed files with 124 additions and 92 deletions
|
@ -1,9 +1,20 @@
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="card mb-3">
|
<div class="card mb-3">
|
||||||
<a href="{{ .Permalink }}" class="index-anchor text-decoration-none">
|
<a href="{{ .Permalink }}" class="index-anchor text-decoration-none">
|
||||||
{{ if .Params.img }}
|
{{- $img := .Params.img -}}
|
||||||
|
{{- $refImg := "" -}}
|
||||||
|
{{- if .Params.imgRef -}}
|
||||||
|
{{- range where .Site.RegularPages "Params.pageid" "eq" .Params.imgRef -}}
|
||||||
|
{{- $refImg = .Params.img -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if not $img -}}
|
||||||
|
{{- $img = $refImg -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{ if $img -}}
|
||||||
|
{{- $image := (resources.Get (printf "img/%s" $img)).Resize "400x" -}}
|
||||||
<img width="100%"
|
<img width="100%"
|
||||||
src="{{ .Site.BaseURL }}img/{{ .Params.img }}" alt="{{ .Title }}">
|
src="{{ $image.RelPermalink }}" alt="{{ .Title }}">
|
||||||
{{ else if .Params.teaser }}
|
{{ 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>
|
||||||
|
|
|
@ -1,8 +1,28 @@
|
||||||
<div class="col-md-4 mt20">
|
<div class="col-md-4 mt20">
|
||||||
|
|
||||||
{{ if .Params.img -}}
|
{{- $refImg := "" -}}
|
||||||
|
{{- $refPage := "" -}}
|
||||||
|
{{- $img := .Params.img -}}
|
||||||
|
{{- if .Params.imgRef -}}
|
||||||
|
{{- range where .Site.RegularPages "Params.pageid" "eq" .Params.imgRef -}}
|
||||||
|
{{- $refImg = .Params.img -}}
|
||||||
|
{{- $refPage = . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if not $img -}}
|
||||||
|
{{- $img = $refImg -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{ if $img -}}
|
||||||
|
{{- $image := (resources.Get (printf "img/%s" $img)).Resize "400x" -}}
|
||||||
|
{{- if $refPage -}}
|
||||||
|
<a href="{{ $refPage.Permalink }}"><img
|
||||||
|
width="100%" class="mt-3"
|
||||||
|
src="{{ $image.RelPermalink }}" alt="{{ .Params.title }}"></a>
|
||||||
|
{{- else -}}
|
||||||
<img width="100%" class="mt-3"
|
<img width="100%" class="mt-3"
|
||||||
src="{{ .Site.BaseURL}}img/{{ .Params.img }}" alt="{{ .Params.title }}">
|
src="{{ $image.RelPermalink }}" alt="{{ .Params.title }}">
|
||||||
|
{{- end -}}
|
||||||
{{- else if .Params.teaser -}}
|
{{- else if .Params.teaser -}}
|
||||||
<div class="card mt-3">
|
<div class="card mt-3">
|
||||||
<div class="card-body bg-light">
|
<div class="card-body bg-light">
|
||||||
|
@ -11,7 +31,8 @@
|
||||||
</div>
|
</div>
|
||||||
{{- else if .Site.Params.defaultImage -}}
|
{{- else if .Site.Params.defaultImage -}}
|
||||||
<img width="100%" class="mt-3"
|
<img width="100%" class="mt-3"
|
||||||
src="{{ .Site.BaseURL }}img/{{ .Site.Params.defaultImage }}" alt="dummy">
|
src="{{ .Site.BaseURL }}img/{{ .Site.Params.defaultImage }}"
|
||||||
|
alt="Default Dmage">
|
||||||
{{- else if .Params.Summary -}}
|
{{- else if .Params.Summary -}}
|
||||||
<div class="card mt-3">
|
<div class="card mt-3">
|
||||||
<div class="card-body bg-light">
|
<div class="card-body bg-light">
|
||||||
|
@ -43,7 +64,7 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{ if and (not .Site.Params.hideChildArticles)
|
{{ if and (not .Site.Params.hideChildArticles)
|
||||||
(ne .Site.Params.showChildArticles "cards") -}}
|
(ne .Site.Params.showChildArticles "sidebar") -}}
|
||||||
{{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}}
|
{{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}}
|
||||||
{{- partial "card-related"
|
{{- partial "card-related"
|
||||||
(dict "related" $related "header" (i18n "child-articles") "id" "children") -}}
|
(dict "related" $related "header" (i18n "child-articles") "id" "children") -}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue