Skip to content

Instantly share code, notes, and snippets.

@alexishida
Last active August 6, 2024 05:24
Show Gist options
  • Save alexishida/650daccc9a2d0e737437442e446f5442 to your computer and use it in GitHub Desktop.
Save alexishida/650daccc9a2d0e737437442e446f5442 to your computer and use it in GitHub Desktop.
Gravatar Service Rails
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