summaryrefslogtreecommitdiffstats
path: root/themes/danix-xyz-hacker/shortcodes/gravatar.html
blob: 7151ee5994c58709b8683e35188efed8af831811 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{{- $email := .Get "email" -}}
{{- $size := .Get "size" | default "256" -}}
{{- $alt := .Get "alt" | default "User avatar" -}}
{{- $class := .Get "class" | default "w-32 h-32 rounded-full" -}}

{{- if $email -}}
  {{- $hash := md5 (trim (strings.ToLower $email)) -}}
  {{- $gravatarURL := printf "https://www.gravatar.com/avatar/%s?s=%s&d=identicon" $hash $size -}}
  <img
    src="{{ $gravatarURL }}"
    alt="{{ $alt }}"
    class="{{ $class }}"
    loading="lazy"
  />
{{- else -}}
  {{- errorf "gravatar shortcode: 'email' parameter is required" -}}
{{- end -}}