Sha256: 513b7c62f51d788f6dbe8a477d3d2c836273ed409cf549f4b8f9450e962d61fa
Contents?: true
Size: 728 Bytes
Versions: 8
Compression:
Stored size: 728 Bytes
Contents
module PolicyManager module ExporterHelper 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) content_tag(:p, "broken image") end end private def save_image(remote_image, path) open(URI(path).path, 'wb') do |file| file << open(remote_image).read end end end end
Version data entries
8 entries across 8 versions & 1 rubygems