{{- $dir := .Get "dir" | default "" -}} {{- $imagesParam := .Get "images" | default "" -}} {{- $class := .Get "class" | default "gallery" -}} {{- if eq $dir "" -}}

gallery shortcode: dir= fehlt

{{- else -}} {{- $base := printf "img/%s" $dir -}} {{- $images := slice -}} {{- if ne $imagesParam "" -}} {{- range (split $imagesParam ",") -}} {{- $img := trim . " " -}} {{- if ne $img "" -}} {{- $images = $images | append $img -}} {{- end -}} {{- end -}} {{- else -}} {{/* Auto: alle Dateien aus static/img/ (über readDir) */}} {{- $path := printf "static/%s" $base -}} {{- range (readDir $path) -}} {{- if not .IsDir -}} {{- $name := .Name -}} {{- $lower := lower $name -}} {{- if or (hasSuffix $lower ".jpg") (hasSuffix $lower ".jpeg") (hasSuffix $lower ".png") (hasSuffix $lower ".webp") -}} {{- $images = $images | append $name -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- if lt (len $images) 1 -}}

Keine Bilder gefunden in /static/{{ $base }}/

{{- else -}}
{{- range $images -}} {{- $src := printf "/%s/%s" $base . -}} {{- end -}}
{{- end -}} {{- end -}}