Last active
August 6, 2024 05:24
-
-
Save alexishida/650daccc9a2d0e737437442e446f5442 to your computer and use it in GitHub Desktop.
Gravatar Service Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GravatarService | |
def self.get(email_address, default_src, size = 40) | |
email_address = email_address.downcase | |
hash = Digest::SHA256.hexdigest(email_address) | |
params = URI.encode_www_form("d" => default_src, "s" => size) | |
image_src = "https://www.gravatar.com/avatar/#{hash}?#{params}" | |
image_src | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment