hugo-toha/layouts/partials/helpers/get-author-image.html
Patrick Magauran a2b3c7fda2
Transition to Hugo Image Processing (#173)
* Update layout to use Hugo Image Processing.

Created shortcode rimg that uses the srcset attribute to display responsive images.

* Copy Static images to assets folder.

* Add image processing to missing components + Update examples

* Fix rendering in https://themes.gohugo.io/

Co-authored-by: Emruz Hossain <emruz@appscode.com>
2020-12-31 20:55:28 +00:00

29 lines
915 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 because its not supported */}}
{{ $authorImage:= resources.Get $authorImage}}
{{ if and $authorImage (ne $authorImage.MediaType.SubType "svg") }}
{{ $authorImage := $authorImage.Fit "120x120" }}
{{ end }}
{{/* return the author image link */}}
{{ return $authorImage.RelPermalink }}