Files

15 lines
553 B
HTML

{{/* dict "page" <post> "width" <px> -> URL of the post banner (`banner:`, or `image:`), resized when it is a bundle image */}}
{{- $url := "" -}}
{{- with (.page.Params.banner | default .page.Params.image) -}}
{{- with $.page.Resources.GetMatch . -}}
{{- if and (eq .MediaType.MainType "image") (ne .MediaType.SubType "svg") -}}
{{- $url = (.Resize (printf "%dx" $.width)).RelPermalink -}}
{{- else -}}
{{- $url = .RelPermalink -}}
{{- end -}}
{{- else -}}
{{- $url = . -}}
{{- end -}}
{{- end -}}
{{- return $url -}}