diff --git a/layouts/_default/shortblock_common.html b/layouts/_default/shortblock_common.html index a8e8413..6c764ae 100644 --- a/layouts/_default/shortblock_common.html +++ b/layouts/_default/shortblock_common.html @@ -1,41 +1,52 @@
- - {{ $rasters := slice "jpeg" "png" }} {{ $newres := "360x250 smart" }} + {{- $image_src := "" }} + {{- $image_alt := "" }} + {{- $image_caption := "" }} {{/* immagine di default */}} - {{- $featimg := (resources.Get "/images/placeholder_elenco.png").RelPermalink -}} + {{- $image := (resources.Get "/images/placeholder_elenco.png") -}} - {{- if .Params.image -}} - {{/* se è stata definita un'immagine featured */}} - {{- $img := .Page.Resources.GetMatch .Params.image -}} - {{- if $img -}} - {{- if in $rasters $img.MediaType.SubType -}} - {{- $img = $img.Fill $newres -}} - {{ end }} - {{- $featimg = $img.RelPermalink -}} - {{- end -}} - {{- else if .Params.featured -}} - {{/* 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 -}} + {{/* priorità maggiore: image_list */}} + {{- if .Params.image_list }} + {{- $image_src = .Params.image_list.src }} + {{- with .Params.image_list.alt }} + {{- $image_alt = . }} + {{- end }} + {{- with .Params.image_list.caption }} + {{- $image_caption = . }} + {{- end }} + {{- end }} - {{ .Params.image_alt }} + {{/* 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 -}} + + {{ $image_alt }}

{{ .Title }}

diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 6311a32..6ea7813 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -23,34 +23,44 @@ {{ partial "tags.html" . }} - {{- 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 -}} {{- $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 -}}
- {{- if in $rasters $img.MediaType.SubType -}} - {{- if gt $img.Height $maxHeight -}} - {{- $img = $img.Resize (printf "x%d webp q50" $maxHeight) -}} - {{- end -}} - {{ .Params.image_alt }} - {{ else }} - {{ .Params.image_alt }} + {{- if gt $image.Height $maxHeight -}} + {{- $image = $image.Resize (printf "x%d webp q50" $maxHeight) -}} {{- end -}} - {{- with .Params.image_caption -}} -
{{- . | markdownify -}}
+ {{ $image_alt }} + {{- with $image_caption -}} +
{{- . | markdownify -}}
{{- end -}}
{{ end }} diff --git a/layouts/_default/taxonomyshortblock.html b/layouts/_default/taxonomyshortblock.html index 552f18c..5ba7873 100644 --- a/layouts/_default/taxonomyshortblock.html +++ b/layouts/_default/taxonomyshortblock.html @@ -1,42 +1,53 @@
+ {{ $newres := "360x250 webp q50 smart" }} - {{ $rasters := slice "jpeg" "png" }} - {{ $newres := "360x250 smart" }} - + {{- $image_src := "" }} + {{- $image_alt := "" }} + {{- $image_caption := "" }} {{/* immagine di default */}} - {{- $featimg := (resources.Get "/images/placeholder_autore.png").RelPermalink -}} + {{- $image := (resources.Get "/images/placeholder_autore.png") -}} - {{- if .Params.image -}} - {{/* se è stata definita un'immagine featured */}} - {{- $img := .Page.Resources.GetMatch .Params.image -}} - {{- if $img -}} - {{- if in $rasters $img.MediaType.SubType -}} - {{- $img = $img.Fill $newres -}} - {{ end }} - {{- $featimg = $img.RelPermalink -}} - {{- end -}} - {{- else if .Params.featured -}} - {{/* 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 -}} + {{/* priorità maggiore: image_list */}} + {{- if .Params.image_list }} + {{- $image_src = .Params.image_list.src }} + {{- with .Params.image_list.alt }} + {{- $image_alt = . }} + {{- end }} + {{- with .Params.image_list.caption }} + {{- $image_caption = . }} + {{- end }} + {{- end }} - {{ .Params.image_alt }} + {{/* 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 -}} + + {{ $image_alt }}

{{ .Title }}

{{ if .Site.Params.show_post_dates | default true }}