Module: Trestle::AvatarHelper
- Defined in:
- app/helpers/trestle/avatar_helper.rb
Instance Method Summary collapse
- #avatar(options = {}) ⇒ Object
- #default_avatar_options ⇒ Object
- #gravatar(email, options = {}) ⇒ Object
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(={}) fallback = .delete(:fallback) if [:fallback] content_tag(:div, .merge()) do concat content_tag(:span, fallback, class: "avatar-fallback") if fallback concat yield if block_given? end end |
#default_avatar_options ⇒ Object
21 22 23 |
# File 'app/helpers/trestle/avatar_helper.rb', line 21 def Trestle::Options.new(class: ["avatar"]) 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, ={}) = { d: "mp" }.merge() url = "https://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.to_s.downcase)}.png" url << "?#{.to_query}" if .any? image_tag(url) end |