class SimpleAttribute::Attributes::Image
Public Instance Methods
attribute_name()
click to toggle source
# File lib/simple_attribute/attributes/image.rb, line 4 def attribute_name 'image' end
media_type()
click to toggle source
# File lib/simple_attribute/attributes/image.rb, line 8 def media_type @media_type ||= begin type = MiniMime.lookup_by_filename(default_value.to_s) type.content_type.to_s.split('/').first end end
render_attribute()
click to toggle source
# File lib/simple_attribute/attributes/image.rb, line 22 def render_attribute content_tag :img, nil, html_options.reverse_merge(src: value) end
render_default_value()
click to toggle source
Calls superclass method
SimpleAttribute::Attributes::Base#render_default_value
# File lib/simple_attribute/attributes/image.rb, line 15 def render_default_value return super unless 'image'.in?(media_type.to_s) default_url = asset_url(default_value) content_tag :img, nil, html_options.reverse_merge(src: default_url) end