hugo-toha/layouts/partials/helpers/get-author-image.html
James Ray fc3b483697
Allow setting GIFS as author image (#394)
Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
2021-08-10 02:39:10 +00:00

29 lines
970 B
HTML

{{ $author:= site.Data.author }}
{{ if (index site.Data site.Language.Lang).author }}
{{ $author = (index site.Data site.Language.Lang).author }}
{{ end }}
{{/* default author image */}}
{{ $authorImage:= "/images/default-avatar.png" }}
{{ if $author.image }}
{{ $authorImage = $author.image }}
{{ end }}
{{/* if author image is provided in author's data, then use that */}}
{{ if eq (printf "%T" .Params.author ) "maps.Params" }}
{{ with .Params.author }}
{{ if .image }}
{{ $authorImage = .image }}
{{ end }}
{{ end }}
{{ end }}
{{/* apply image processing. don't use "Fit" in svg or gif because its not supported */}}
{{ $authorImage:= resources.Get $authorImage}}
{{ if and $authorImage (and (ne $authorImage.MediaType.SubType "svg") ( ne $authorImage.MediaType.SubType "gif")) }}
{{ $authorImage = $authorImage.Fit "120x120" }}
{{ end }}
{{/* return the author image link */}}
{{ return $authorImage.RelPermalink }}