supporto per image-post e image-list
All checks were successful
Linting markdown on PR / unicode-check (pull_request) Successful in 2m19s
All checks were successful
Linting markdown on PR / unicode-check (pull_request) Successful in 2m19s
This commit is contained in:
parent
a0a417f236
commit
1aacef7869
@ -1,41 +1,52 @@
|
|||||||
<div class="box post">
|
<div class="box post">
|
||||||
|
|
||||||
{{ $rasters := slice "jpeg" "png" }}
|
|
||||||
{{ $newres := "360x250 smart" }}
|
{{ $newres := "360x250 smart" }}
|
||||||
|
|
||||||
|
{{- $image_src := "" }}
|
||||||
|
{{- $image_alt := "" }}
|
||||||
|
{{- $image_caption := "" }}
|
||||||
{{/* immagine di default */}}
|
{{/* immagine di default */}}
|
||||||
{{- $featimg := (resources.Get "/images/placeholder_elenco.png").RelPermalink -}}
|
{{- $image := (resources.Get "/images/placeholder_elenco.png") -}}
|
||||||
|
|
||||||
{{- if .Params.image -}}
|
{{/* priorità maggiore: image_list */}}
|
||||||
{{/* se è stata definita un'immagine featured */}}
|
{{- if .Params.image_list }}
|
||||||
{{- $img := .Page.Resources.GetMatch .Params.image -}}
|
{{- $image_src = .Params.image_list.src }}
|
||||||
{{- if $img -}}
|
{{- with .Params.image_list.alt }}
|
||||||
{{- if in $rasters $img.MediaType.SubType -}}
|
{{- $image_alt = . }}
|
||||||
{{- $img = $img.Fill $newres -}}
|
{{- end }}
|
||||||
{{ end }}
|
{{- with .Params.image_list.caption }}
|
||||||
{{- $featimg = $img.RelPermalink -}}
|
{{- $image_caption = . }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- else if .Params.featured -}}
|
{{- end }}
|
||||||
{{/* se è stata definita un'immagine featured */}}
|
|
||||||
{{- $img := .Page.Resources.GetMatch .Params.featured -}}
|
|
||||||
{{- if $img -}}
|
|
||||||
{{- if in $rasters $img.MediaType.SubType -}}
|
|
||||||
{{- $img = $img.Fill $newres -}}
|
|
||||||
{{ end }}
|
|
||||||
{{- $featimg = $img.RelPermalink -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- else -}}
|
|
||||||
{{/* altrimenti prendo la prima risorsa immagine disponibile */}}
|
|
||||||
{{- $img := (.Page.Resources.ByType "image").GetMatch "**" -}}
|
|
||||||
{{- if $img -}}
|
|
||||||
{{- if in $rasters $img.MediaType.SubType -}}
|
|
||||||
{{- $img = $img.Fill $newres -}}
|
|
||||||
{{ end }}
|
|
||||||
{{- $featimg = $img.RelPermalink -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
<a href="{{ .RelPermalink }}" class="image left"><img src="{{ $featimg }}" alt="{{ .Params.image_alt }}" /></a>
|
{{/* in alternativa: image_post */}}
|
||||||
|
{{- if and (not $image_src) .Params.image_post }}
|
||||||
|
{{- $image_src = .Params.image_post.src }}
|
||||||
|
{{- with .Params.image_post.alt }}
|
||||||
|
{{- $image_alt = . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Params.image_post.caption }}
|
||||||
|
{{- $image_caption = . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{/* in alternativa uso il metodo vecchio */}}
|
||||||
|
{{- if and (not $image_src) .Params.image }}
|
||||||
|
{{- $image_src = .Params.image }}
|
||||||
|
{{- with .Params.image_alt }}
|
||||||
|
{{- $image_alt = . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Params.image_caption }}
|
||||||
|
{{- $image_caption = . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if $image_src }}
|
||||||
|
{{- $image = .Page.Resources.GetMatch $image_src }}
|
||||||
|
{{- end}}
|
||||||
|
|
||||||
|
{{- $image = $image.Fill $newres -}}
|
||||||
|
|
||||||
|
<a href="{{ .RelPermalink }}" class="image left"><img src="{{ $image.RelPermalink }}" alt="{{ $image_alt }}" /></a>
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
<h3><a href="{{ .RelPermalink }}">{{ .Title }}</a></h3>
|
<h3><a href="{{ .RelPermalink }}">{{ .Title }}</a></h3>
|
||||||
|
|
||||||
|
@ -23,34 +23,44 @@
|
|||||||
{{ partial "tags.html" . }}
|
{{ partial "tags.html" . }}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
{{- if or .Params.image .Params.featured }}
|
{{- $image_src := "" }}
|
||||||
|
{{- $image_alt := "" }}
|
||||||
|
{{- $image_caption := "" }}
|
||||||
|
|
||||||
|
{{/* priorità maggiore: image_post */}}
|
||||||
|
{{- if .Params.image_post }}
|
||||||
|
{{- $image_src = .Params.image_post.src }}
|
||||||
|
{{- with .Params.image_post.alt }}
|
||||||
|
{{- $image_alt = . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Params.image_post.caption }}
|
||||||
|
{{- $image_caption = . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{/* in alternativa uso il metodo vecchio */}}
|
||||||
|
{{- if and (not $image_src) .Params.image }}
|
||||||
|
{{- $image_src = .Params.image }}
|
||||||
|
{{- with .Params.image_alt }}
|
||||||
|
{{- $image_alt = . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Params.image_caption }}
|
||||||
|
{{- $image_caption = . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if $image_src }}
|
||||||
|
{{- $image := .Page.Resources.GetMatch $image_src }}
|
||||||
{{- $maxHeight := 600 -}}
|
{{- $maxHeight := 600 -}}
|
||||||
{{- $ratio := 2.33 -}}
|
{{- $ratio := 2.33 -}}
|
||||||
{{ $rasters := slice "jpeg" "png" }}
|
|
||||||
{{- $img := "#" -}}
|
|
||||||
|
|
||||||
{{- if .Params.image -}}
|
|
||||||
{{/* se è stata definita un'immagine featured */}}
|
|
||||||
{{- $img = .Page.Resources.GetMatch .Params.image -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- if .Params.featured -}}
|
|
||||||
{{/* se è stata definita un'immagine featured */}}
|
|
||||||
{{- $img = .Page.Resources.GetMatch .Params.featured -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
<span class="image featured"><figure>
|
<span class="image featured"><figure>
|
||||||
{{- if in $rasters $img.MediaType.SubType -}}
|
{{- if gt $image.Height $maxHeight -}}
|
||||||
{{- if gt $img.Height $maxHeight -}}
|
{{- $image = $image.Resize (printf "x%d webp q50" $maxHeight) -}}
|
||||||
{{- $img = $img.Resize (printf "x%d webp q50" $maxHeight) -}}
|
|
||||||
{{- end -}}
|
|
||||||
<img src="{{ $img.RelPermalink }}" alt="{{ .Params.image_alt }}" {{- if ge (mul $img.Height $ratio) $img.Width -}}style="width: auto;" {{- end -}}/>
|
|
||||||
{{ else }}
|
|
||||||
<img src="{{ $img.RelPermalink }}" alt="{{ .Params.image_alt }}" />
|
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- with .Params.image_caption -}}
|
<img src="{{ $image.RelPermalink }}" alt="{{ $image_alt }}" {{- if ge (mul $image.Height $ratio) $image.Width -}}style="width: auto;" {{- end -}}/>
|
||||||
<figcaption style="max-width: {{- $img.Width -}}px;">{{- . | markdownify -}}</figcaption>
|
{{- with $image_caption -}}
|
||||||
|
<figcaption style="max-width: {{- $image.Width -}}px;">{{- . | markdownify -}}</figcaption>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
</figure></span>
|
</figure></span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -1,42 +1,53 @@
|
|||||||
<section>
|
<section>
|
||||||
<div class="box post">
|
<div class="box post">
|
||||||
|
{{ $newres := "360x250 webp q50 smart" }}
|
||||||
|
|
||||||
{{ $rasters := slice "jpeg" "png" }}
|
{{- $image_src := "" }}
|
||||||
{{ $newres := "360x250 smart" }}
|
{{- $image_alt := "" }}
|
||||||
|
{{- $image_caption := "" }}
|
||||||
{{/* immagine di default */}}
|
{{/* immagine di default */}}
|
||||||
{{- $featimg := (resources.Get "/images/placeholder_autore.png").RelPermalink -}}
|
{{- $image := (resources.Get "/images/placeholder_autore.png") -}}
|
||||||
|
|
||||||
{{- if .Params.image -}}
|
{{/* priorità maggiore: image_list */}}
|
||||||
{{/* se è stata definita un'immagine featured */}}
|
{{- if .Params.image_list }}
|
||||||
{{- $img := .Page.Resources.GetMatch .Params.image -}}
|
{{- $image_src = .Params.image_list.src }}
|
||||||
{{- if $img -}}
|
{{- with .Params.image_list.alt }}
|
||||||
{{- if in $rasters $img.MediaType.SubType -}}
|
{{- $image_alt = . }}
|
||||||
{{- $img = $img.Fill $newres -}}
|
{{- end }}
|
||||||
{{ end }}
|
{{- with .Params.image_list.caption }}
|
||||||
{{- $featimg = $img.RelPermalink -}}
|
{{- $image_caption = . }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- else if .Params.featured -}}
|
{{- end }}
|
||||||
{{/* se è stata definita un'immagine featured */}}
|
|
||||||
{{- $img := .Page.Resources.GetMatch .Params.featured -}}
|
|
||||||
{{- if $img -}}
|
|
||||||
{{- if in $rasters $img.MediaType.SubType -}}
|
|
||||||
{{- $img = $img.Fill $newres -}}
|
|
||||||
{{ end }}
|
|
||||||
{{- $featimg = $img.RelPermalink -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- else -}}
|
|
||||||
{{/* altrimenti prendo la prima risorsa immagine disponibile */}}
|
|
||||||
{{- $img := (.Page.Resources.ByType "image").GetMatch "**" -}}
|
|
||||||
{{- if $img -}}
|
|
||||||
{{- if in $rasters $img.MediaType.SubType -}}
|
|
||||||
{{- $img = $img.Fill $newres -}}
|
|
||||||
{{ end }}
|
|
||||||
{{- $featimg = $img.RelPermalink -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
<a href="{{ .RelPermalink }}" class="image left"><img src="{{ $featimg }}" alt="{{ .Params.image_alt }}" /></a>
|
{{/* in alternativa: image_post */}}
|
||||||
|
{{- if and (not $image_src) .Params.image_post }}
|
||||||
|
{{- $image_src = .Params.image_post.src }}
|
||||||
|
{{- with .Params.image_post.alt }}
|
||||||
|
{{- $image_alt = . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Params.image_post.caption }}
|
||||||
|
{{- $image_caption = . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{/* in alternativa uso il metodo vecchio */}}
|
||||||
|
{{- if and (not $image_src) .Params.image }}
|
||||||
|
{{- $image_src = .Params.image }}
|
||||||
|
{{- with .Params.image_alt }}
|
||||||
|
{{- $image_alt = . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Params.image_caption }}
|
||||||
|
{{- $image_caption = . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if $image_src }}
|
||||||
|
{{- $image = .Page.Resources.GetMatch $image_src }}
|
||||||
|
{{- end}}
|
||||||
|
|
||||||
|
{{- $image = $image.Fill $newres -}}
|
||||||
|
|
||||||
|
<a href="{{ .RelPermalink }}" class="image left"><img src="{{ $image.RelPermalink }}" alt="{{ $image_alt }}" /></a>
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
<h3><a href="{{ .RelPermalink }}">{{ .Title }}</a></h3>
|
<h3><a href="{{ .RelPermalink }}">{{ .Title }}</a></h3>
|
||||||
{{ if .Site.Params.show_post_dates | default true }}
|
{{ if .Site.Params.show_post_dates | default true }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user