selfprivacy.org/layouts/shortcodes/responsive-carousel.html
2024-12-11 20:28:25 +03:00

35 lines
1.2 KiB
HTML

{{ $lang := ( .Get 0 ) }}
{{ $srcFiles := (resources.Match (printf "images/screenshots/%s/*" $lang)) }}
{{ $tinyw := default "500" }}
{{ $smallw := default "800" }}
{{ $mediumw := default "1200" }}
{{ $largew := default "2400" }}
{{ range $i, $src := $srcFiles }}
{{ $tiny := $src.Resize (printf "%sx" $tinyw) }}
{{ $small := $src.Resize (printf "%sx" $smallw) }}
{{ $medium:= $src.Resize (printf "%sx" $mediumw) }}
{{ $large := $src.Resize (printf "%sx" $largew) }}
<div class="carousel-item {{ if eq $i 0 }} active {{ end }}">
<img
class = "w-100"
srcset='
{{ with $tiny.RelPermalink }}{{.}} {{(printf "%sw" $tinyw)}} {{ end }},
{{ with $small.RelPermalink }}{{.}} {{(printf "%sw" $smallw)}} {{ end }},
{{ with $medium.RelPermalink }}{{.}} {{(printf "%sw" $mediumw)}} {{ end }},
{{ with $large.RelPermalink }}{{.}} {{(printf "%sw" $largew)}} {{ end }}
'
sizes='
(max-width: {{(printf "%spx" $tinyw)}}) {{(printf "%spx" $tinyw)}},
(max-width: {{(printf "%spx" $smallw)}}) {{(printf "%spx" $smallw)}},
(max-width: {{(printf "%spx" $mediumw)}}) {{(printf "%spx" $mediumw)}},
(max-width: {{(printf "%spx" $largew)}}) {{(printf "%spx" $largew)}},
100%
'
>
</div>
{{ end }}