Module: GravatarImageTag::InstanceMethods

Defined in:
lib/gravatar_image_tag.rb

Instance Method Summary collapse

Instance Method Details

#gravatar_image_tag(email, options = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/gravatar_image_tag.rb', line 64

def gravatar_image_tag(email, options = {})
  gravatar_overrides = options.delete(:gravatar)
  options[:src] = gravatar_image_url(email, gravatar_overrides)
  options[:alt] ||= 'Gravatar'
  if GravatarImageTag.configuration.include_size_attributes
    size = GravatarImageTag::gravatar_options(gravatar_overrides)[:size] || 80
    options[:height] = options[:width] = size.to_s
  end

  # Patch submitted to rails to allow image_tag here
  # https://rails.lighthouseapp.com/projects/8994/tickets/2878
  tag 'img', options, false, false
end

#gravatar_image_url(email, gravatar_overrides = {}) ⇒ Object



78
79
80
81
# File 'lib/gravatar_image_tag.rb', line 78

def gravatar_image_url(email, gravatar_overrides = {})
  email = email.strip.downcase if email.is_a? String
  GravatarImageTag::gravatar_url(email, gravatar_overrides)
end