gravatar.rb 528 Bytes
Newer Older
1
# modified from https://tlattimore.com/blog/using-gravatar-in-jekyll/
2 3 4 5
require 'digest/md5'

module Jekyll
  module GravatarFilter
6 7
    # Add our new liquid filter.
    def get_gravatar(input)
8
      "//www.gravatar.com/avatar/#{hash(input)}?d=mm"
9 10
    end

11
    private :hash
12

13 14 15 16
    # Clean up the email address and return hashed version.
    def hash(email)
      email_address = email ? email.downcase.strip : ''
      Digest::MD5.hexdigest(email_address)
17 18 19
    end
  end
end
20

21
Liquid::Template.register_filter(Jekyll::GravatarFilter)