{{- $image_path := .image_path -}} {{- $site_image_dir := (or .context.Site.Params.image_dir "/images") -}} {{- $site_responsive_image_dir := (or .context.Site.Params.responsive_image_dir "/responsive-images") -}} {{- $image_extension := path.Ext .image_path -}} {{- $image_path_no_ext := strings.TrimSuffix $image_extension $image_path -}} {{ $common_image_path := trim (strings.TrimPrefix $site_image_dir $image_path) " "}} {{- $image_dir := path.Dir $image_path -}} {{- $cloned_image_dir := replace $image_dir $site_image_dir $site_responsive_image_dir -}} {{- if fileExists (print "static/" $cloned_image_dir) -}} {{ $all_responsive_images := (partial "hugo-sundries/recursive-readdir.html" (path.Join "static/" $cloned_image_dir))}} {{- $size_versions := slice -}} {{- range $all_responsive_images -}} {{ $responsive_image_path := . }} {{ $public_responsive_image_path := strings.TrimPrefix (print "static" $site_responsive_image_dir) $responsive_image_path }} {{ $test := partial "hugo-sundries/responsive-image-common-name.html" $public_responsive_image_path}} {{- if (eq $common_image_path $test) -}} {{- $size_versions = $size_versions | append ( strings.TrimPrefix "static" . ) -}} {{- end -}} {{- end -}} {{- $items := slice -}} {{- range $size_versions -}} {{- $this_image_extension := path.Ext . -}} {{- $this_image_path_no_ext := strings.TrimSuffix $this_image_extension . -}} {{- $size := (index (last 1 (split $this_image_path_no_ext "-")) 0) -}} {{- $items = $items | append (print . " " $size) -}} {{- end -}} {{- delimit $items ", " -}} {{ else }} {{ $image_path}} {{- end -}}