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