{{- $img := "" }} {{- $validKeyword := false }} {{- if .keyword }} {{- if (.context.Resources.ByType "image").GetMatch .keyword }} {{- $validKeyword = true}} {{- end }} {{- end }} {{- if $validKeyword }} {{- $img = ((.context.Resources.ByType "image").GetMatch .keyword).Permalink }} {{- else if resources.GetMatch .url }} {{- $img = (resources.GetMatch .url).Permalink }} {{- else if .url }} {{- $img = (.url | absURL) }} {{- end }} {{- return $img }}