0.01
No commit activity in last 3 years
No release in over 3 years
A simple up to date gem for creating Gravatar image URL's and tags
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

rb-gravatar

A simple and up to date Ruby Gem for generating Gravatar images and tags.

Installation

gem install rb-gravatar

Example Usage

require 'rb-gravatar'

# Generate only the image URL
puts Gravatar.src('you@you.com')
puts Gravatar.src('you@you.com', 32)
puts Gravatar.src('you@you.com', 32, 'http://you.com/image.png')
# Result: http://www.gravatar.com/avatar/d7f390bdf9f44bd8f460ac1aff05a603?s=32&d=http%3A%2F%2Fyou.com%2Fimage.png

# Generate the whole image tag
puts Gravatar.tag('you@you.com')
puts Gravatar.tag('you@you.com', 32)
puts Gravatar.tag('you@you.com', 32, 'http://you.com/image.png', 'The image alt text') 
# Result: <img src='http://www.gravatar.com/avatar/d7f390bdf9f44bd8f460ac1aff05a603?s=32&d=http%3A%2F%2Fyou.com%2Fimage.png' />

Using with Rails

Rails will automatically escape the text generated by the plugin when you try output it in your views, as a result, you need to use the Rails raw helper:

<%= raw Gravatar.src('you@you.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() %>

License

Please see LICENSE for licensing details.

Author

github.com/sn