Cleaner and shorter statement?

I use the conditional operator if the thumbnail exists and the code below works, but I’m wondering if it could be written cleaner and shorter? Something like Ternary?

{{- $itemImg := (index (.Resources.ByType "image") 0) }}
{{ if (index (.Resources.Match "thumb/*") 0) -}}
{{- $itemImg = (index (.Resources.Match "thumb/*") 0) }}
{{- end }}
{{ $itemImg := or (.Resources.GetMatch "thumb/*") (index (.Resources.ByType "image") 0) }}
1 Like

Great! Thanks a lot.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.