Module: PhantomHelpers::ViewHelpers::ImageHelper

Defined in:
lib/phantom_helpers/view_helpers/image_helper.rb

Instance Method Summary collapse

Instance Method Details

#boolean_image(field) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/phantom_helpers/view_helpers/image_helper.rb', line 5

def boolean_image(field)
  if field
    image_tag('tick.png')
  else
    image_tag('cross.png')
  end
end

#resize_image(image_url, options = {}) ⇒ Object



13
14
15
16
17
18
# File 'lib/phantom_helpers/view_helpers/image_helper.rb', line 13

def resize_image(image_url, options = {})
  raise 'No size given use :size or :width & :height' unless options[:size] || (options[:height] && options[:width])
  height = options[:height] || options[:size]
  width  = options[:width]  || options[:size]
  image_tag(image_url, style: "height:#{height}px;width:#{width}px") unless image_url.blank?
end