A simple gem for for generating Gravatar images and tags in a Rails environment.
gem install rails_gravatar
require 'rails_gravatar'
# Generate only the image URL
RailsGravatar.src("[email protected]")
RailsGravatar.src("[email protected]", 32) # with size
RailsGravatar.src("[email protected]", 32, "http://email.com/image.png") # with fallback image url
# Generate the whole image tag
RailsGravatar.tag("[email protected]")
RailsGravatar.tag("[email protected]", 32) # with size
RailsGravatar.tag("[email protected]", 32, "http://email.com/image.png", "The image alt text") # with fallback image url
Because we are using the Rails tag helpers, you do not need to use tag helpers such as raw
or .html_safe
.
<%= Gravatar.src("[email protected]") %>
Gravatar.src(email_address, size, default_image_url)
Gravatar.tag(email_address, size, default_image_url, alt_text)
You can also automatically add the DNS prefetch tag to your page headers using:
<%= Gravatar.prefetch_dns_tag %>
bundle exec rspec
Please see LICENSE for licensing details. This code is MIT licensed and will ALWAYS be MIT licensed.
https://github.com/mission-met https://github.com/rickychilcott