Module: ActionView::Helpers::AssetTagHelper

Defined in:
lib/lorempixum.rb

Instance Method Summary collapse

Instance Method Details

#placeholder_image_tag(options = {}) ⇒ Object Also known as: lorempixum_image_tag


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lorempixum.rb', line 4

def placeholder_image_tag(options = {})
  source = "http://lorempixum.com"
  options[:alt] = "lorempixum" unless options.has_key?(:alt)

  # gray
  if options.has_key?(:gray)
    source += "/g" if options[:gray]
    options.delete(:gray)
  end

  # width
  width = options.has_key?(:width) ? options[:width] : 100
  source += "/#{width}"

  # height
  height = options.has_key?(:height) ? options[:height] : 100
  source += "/#{height}"

  # category
  if options.has_key?(:category)
    source += "/#{options.delete(:category)}"

    # number
    source += "/#{options.delete(:number)}" if options.has_key?(:number)
  end

  image_tag(source, options)
end