130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'app/helpers/sibu/pages_helper.rb', line 130
def img(elt, opts = {})
wrapper = opts.delete(:wrapper)
repeat = opts.delete(:repeat)
size = opts.delete(:size)
t_id = elt.is_a?(Hash) ? elt["id"] : elt
defaults = {"id" => t_id, "src" => Sibu::DEFAULT_IMG}
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
@sb_section = (@sb_section || []) + [t_id]
if action_name == 'show'
content["src"] = ("/#{conf[:deployment_path]}" + content["src"]) if @online && conf[:deployment_path]
else
opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "media", repeat: repeat, size: size}})
end
html_output = wrapper ? content_tag(wrapper, content_tag(:img, nil, content.except("id")), opts)
: content_tag(:img, nil, content.except("id").merge(opts.stringify_keys) {|k, old, new| k == 'class' ? [old, new].join(' ') : new})
@sb_section -= [t_id]
html_output
end
|