Module: PolicyManager::ExporterHelper

Included in:
ExporterController
Defined in:
app/helpers/policy_manager/exporter_helper.rb

Instance Method Summary collapse

Instance Method Details

#image_tag(remote_image, opts = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/policy_manager/exporter_helper.rb', line 4

def image_tag(remote_image, opts={})
  begin
    basename = File.basename(remote_image)
    id = opts[:id] || SecureRandom.hex(10)
    composed_name = [id, basename].compact.join("-")
    path = "#{File.dirname(@base_path)}/#{composed_name}"
    save_image(remote_image, path)
    tag(:img, {src: "./#{id}-#{File.basename(URI(remote_image).path)}" }.merge(opts))
  rescue => e
    Config.error_notifier_method(e)
    (:p, "broken image")
  end
end