didascalie immagini (con supporto markdown) #156

Merged
paspo merged 1 commits from paspo/bglug.it:image-credits into main 2024-07-27 22:59:45 +00:00
4 changed files with 32 additions and 6 deletions

View File

@ -47,3 +47,14 @@
max-width: 100% max-width: 100%
} }
} }
figure {
display: inline-block;
}
figcaption {
width: 100%;
text-align: center;
font-size: smaller;
font-style: italic;
}

View File

@ -5,6 +5,8 @@ type: post
date: 2023-10-24T16:37:38+00:00 date: 2023-10-24T16:37:38+00:00
slug: linux-day-2023-agenda slug: linux-day-2023-agenda
image: LDbergamo-2023-banner.png image: LDbergamo-2023-banner.png
image_alt: Linuxday il 28 ottobre 2023 presso Bergamo Science Center
image_caption: "Image credits: [BgLUG](https://bglug.it 'Bergamo Linux Users Group website')"
categories: categories:
- News - News
--- ---
@ -13,10 +15,10 @@ Ecco l'agenda del LinuxDay '23.
[Iscriviti su EVENTBRITE](https://www.eventbrite.it/e/biglietti-bglug-linuxday-23-744247924577?aff=oddtdtcreator). [Iscriviti su EVENTBRITE](https://www.eventbrite.it/e/biglietti-bglug-linuxday-23-744247924577?aff=oddtdtcreator).
![Locandina Linux Day Bergamo 2023](LDbergamo-2023-3.png) ![Locandina Linux Day Bergamo 2023](LDbergamo-2023-3.png "Image credits: [BgLUG](https://bglug.it 'Bergamo Linux Users Group website')")
La lettura di **Ada&Zangemann** si svolgerà al [FabLab Bergamo APS in via M.Gavazzeni 3](https://www.openstreetmap.org/node/4712453185), poco lontano dall'evento principale. La lettura di **Ada&Zangemann** si svolgerà al [FabLab Bergamo APS in via M.Gavazzeni 3](https://www.openstreetmap.org/node/4712453185), poco lontano dall'evento principale.
![2Ada & Zangemann](ADA-E-ZAG-3.gif) ![2Ada & Zangemann](ADA-E-ZAG-3.gif "Image credits: [BgLUG](https://bglug.it 'Bergamo Linux Users Group website')")
[Link canva](https://tiny.cc/ada-zangemann). [Link canva](https://tiny.cc/ada-zangemann).

View File

@ -1,5 +1,8 @@
<figure>
{{- $u := urls.Parse .Destination -}} {{- $u := urls.Parse .Destination -}}
{{- $src := $u.String -}} {{- $src := $u.String -}}
{{- $figcaption := .Title | markdownify -}}
{{- $captionWidth := 0 -}}
{{- if not $u.IsAbs -}} {{- if not $u.IsAbs -}}
{{- $path := strings.TrimPrefix "./" $u.Path }} {{- $path := strings.TrimPrefix "./" $u.Path }}
{{- with or (.PageInner.Resources.Get $path) (resources.Get $path) -}} {{- with or (.PageInner.Resources.Get $path) (resources.Get $path) -}}
@ -14,13 +17,20 @@
{{- with $u.Fragment -}} {{- with $u.Fragment -}}
{{- $src = printf "%s#%s" $src . -}} {{- $src = printf "%s#%s" $src . -}}
{{- end -}} {{- end -}}
{{- $captionWidth = .Width -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- $attributes := merge .Attributes (dict "alt" .Text "src" $src "title" (.Title | transform.HTMLEscape)) -}} {{- $attributes := merge .Attributes (dict "alt" .Text "src" $src "title" (.Title | transform.HTMLEscape)) -}}
<img <img
{{- range $k, $v := $attributes -}} {{- range $k, $v := $attributes -}}
{{- if $v -}} {{- if $v -}}
{{- printf " %s=%q" $k $v | safeHTMLAttr -}} {{- printf " %s=%q" $k $v | safeHTMLAttr -}}
{{- end -}} {{- end -}}
{{- end -}}> {{- end -}}>
{{- with $figcaption -}}
<figcaption
{{ with $captionWidth }} style="width: {{- . -}}px;"
{{- end -}}>{{- . -}}</figcaption>
{{- end -}}
</figure>
{{- /**/ -}} {{- /**/ -}}

View File

@ -25,7 +25,7 @@
{{- $img = .Page.Resources.GetMatch .Params.featured -}} {{- $img = .Page.Resources.GetMatch .Params.featured -}}
{{- end -}} {{- end -}}
<span class="image featured"> <span class="image featured"><figure>
{{- if in $rasters $img.MediaType.SubType -}} {{- if in $rasters $img.MediaType.SubType -}}
{{- if gt $img.Height $maxHeight -}} {{- if gt $img.Height $maxHeight -}}
{{- $img = $img.Resize (printf "x%d webp q50" $maxHeight) -}} {{- $img = $img.Resize (printf "x%d webp q50" $maxHeight) -}}
@ -33,8 +33,11 @@
<img src="{{ $img.RelPermalink }}" alt="{{ .Params.image_alt }}" {{- if ge (mul $img.Height $ratio) $img.Width -}}style="width: auto;" {{- end -}}/> <img src="{{ $img.RelPermalink }}" alt="{{ .Params.image_alt }}" {{- if ge (mul $img.Height $ratio) $img.Width -}}style="width: auto;" {{- end -}}/>
{{ else }} {{ else }}
<img src="{{ $img.RelPermalink }}" alt="{{ .Params.image_alt }}" /> <img src="{{ $img.RelPermalink }}" alt="{{ .Params.image_alt }}" />
{{ end }} {{- end -}}
</span> {{- with .Params.image_caption -}}
<figcaption style="width: {{- $img.Width -}}px;">{{- . | markdownify -}}</figcaption>
{{- end -}}
</figure></span>
{{ end }} {{ end }}
{{- .Content }} {{- .Content }}