9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/artwork/view.rb', line 9
def artwork_tag(record, attachment_name, size, options = {})
image_tag_options = options[:image] || {}
img_holder_options = options[:img_holder] || {}
image_tag_options[:alt] ||= (record)
image_url = record.artwork_url attachment_name, size, options
if options[:auto_height]
image = record.send(attachment_name)
if image.height.present? and image.width.present?
padding = ((image.height.to_f / image.width) * 100).round(4)
img_holder_options[:style] = "padding-bottom:#{padding}%;"
end
end
content_tag :div, :class => attachment_name do
content_tag :div, img_holder_options.merge(:class => 'img-holder') do
image_tag image_url, image_tag_options
end
end
end
|