Module: Trestle::AvatarHelper

Defined in:
app/helpers/trestle/avatar_helper.rb

Instance Method Summary collapse

Instance Method Details

#avatar(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
# File 'app/helpers/trestle/avatar_helper.rb', line 3

def avatar(options={})
  fallback = options.delete(:fallback) if options[:fallback]

  (:div, options.reverse_merge(class: "avatar")) do
    concat (:span, fallback, class: "avatar-fallback") if fallback
    concat yield if block_given?
  end
end

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



12
13
14
15
16
17
18
19
# File 'app/helpers/trestle/avatar_helper.rb', line 12

def gravatar(email, options={})
  options = { d: "mm" }.merge(options)

  url = "https://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.to_s.downcase)}.png"
  url << "?#{options.to_query}" if options.any?

  image_tag(url)
end