public
Description: Rails plugin for uploading images as resources, with support for resizing, text stamping, and other special effects.
Homepage: http://fleximage.rubyforge.org
Clone URL: git://github.com/Squeegy/fleximage.git
commit  acc62eeab73be0f8a6a0622c9fb3358802f0ad00
tree    0a70f32f08a147b9ce9d2db784125ab47db2c7d8
parent  305defb7de03acd9ccc01ab05caa3ca302a07a91
fleximage / lib / fleximage / helper.rb
100644 19 lines (16 sloc) 0.602 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Fleximage
  module Helper
    def embedded_image_tag(model_object, options = {})
      model_object.load_image
      format = options[:format] || :jpg
      mime = Mime::Type.lookup_by_extension(format.to_s).to_s
      image = model_object.output_image(:format => format)
      data = Base64.encode64(image)
      
      options = { :alt => model_object.class.to_s }.merge(options)
      
      result = image_tag("data:#{mime};base64,#{data}", options)
      result.gsub('/images/data:', 'data:')
      
    rescue Fleximage::Model::MasterImageNotFound => e
      nil
    end
  end
end