get-author-image.html 915 B

1234567891011121314151617181920212223242526272829
  1. {{ $author:= site.Data.author }}
  2. {{ if (index site.Data site.Language.Lang).author }}
  3. {{ $author = (index site.Data site.Language.Lang).author }}
  4. {{ end }}
  5. {{/* default author image */}}
  6. {{ $authorImage:= "/images/default-avatar.png" }}
  7. {{ if $author.image }}
  8. {{ $authorImage = $author.image }}
  9. {{ end }}
  10. {{/* if author image is provided in author's data, then use that */}}
  11. {{ if eq (printf "%T" .Params.author ) "maps.Params" }}
  12. {{ with .Params.author }}
  13. {{ if .image }}
  14. {{ $authorImage = .image }}
  15. {{ end }}
  16. {{ end }}
  17. {{ end }}
  18. {{/* apply image processing. don't use "Fit" in svg because its not supported */}}
  19. {{ $authorImage:= resources.Get $authorImage}}
  20. {{ if and $authorImage (ne $authorImage.MediaType.SubType "svg") }}
  21. {{ $authorImage := $authorImage.Fit "120x120" }}
  22. {{ end }}
  23. {{/* return the author image link */}}
  24. {{ return $authorImage.RelPermalink }}