3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/responsive_image/helpers.rb', line 3
def self.create_picture(image, options = {})
extension = File.extname(image)
filename = File.basename(image, extension)
if options[:config]
ResponsiveImage.media_types = options[:config]
end
if options[:host]
ResponsiveImage.host = options[:host]
end
element = ""
element = "<picture>"
element << "<!--[if IE 9]><video style='display: none;'><![endif]-->"
ResponsiveImage.media_types.each do |source|
srcfile = "#{filename}-#{source[:filename_suffix]}#{extension}"
element << "<source srcset='#{ResponsiveImage.host}#{image_url(srcfile)}' media='#{source[:media_query]}'>"
end
element << "<!--[if IE 9]></video><![endif]-->"
element << "<img srcset='#{ResponsiveImage.host}#{image_url(image)}' class='#{options[:html] ? options[:html][:class] : nil}' alt='#{options[:html] ? options[:html][:alt] : nil}'>"
element << "</picture>"
element
end
|