Module | Gravatarify |
In: |
lib/gravatarify/version.rb
lib/gravatarify/base.rb lib/gravatarify/helper.rb lib/gravatarify/utils.rb lib/gravatarify.rb |
Provides support for adding gravatar images in ruby (and rails) applications.
VERSION | = | "3.1.1" | current API version, as defined by semver.org/ | |
GRAVATAR_ABBREV_OPTIONS | = | { 'default' => :d, :default => :d, 'rating' => :r, :rating => :r, 'size' => :s, :size => :s } | Hash of :ultra_long_option_name => :abbr_opt |
Global options which are merged on every call to gravatar_url, this is useful to e.g. define a default image.
When using Rails defining default options is best done in an initializer +config/initializers/gravatarify.rb+ (or similar).
Usage examples:
# set the default image using a Proc Gravatarify.options[:default] = Proc.new { |*args| "http://example.com/avatar-#{args.first[:size] || 80}.jpg" } # or set a custom default rating Gravatarify.options[:rating] = :R # or disable adding an extension Gravatarify.options[:filetype] = false
Allows to define some styles, makes it simpler to call by name, instead of always giving a size etc.
Gravatarify.styles[:mini] => { :size => 30, :default => "http://example.com/gravatar-mini.jpg" } # in the views, it will then use the stuff defined by styles[:mini]: <%= gravatar_tag @user, :mini %>
Globally overide subdomains used to build gravatar urls, normally gravatarify picks from either +0.gravatar.com+, +1.gravatar.com+, +2.gravatar.com+, +3.gravater.com+ or +www.gravatar.com+ when building hosts, to use a custom set of subdomains (or none!) do something like:
Gravatarify.subdomains = %w{ 0 www } # only use 0.gravatar.com and www.gravatar.com