Class Mw::ImageComponentController
In: components/mw/image_component_controller.rb
Parent: ApplicationController

Image component renders images.

Example:

  class GalleryController < Application
    ....
    def show
      render_component :controller => 'mw/ImageComponent',
                                           :action => 'show',
                                           :params => { :image  => @params[:id],
                                                                    :limit_size => @params[:limit_size],
                                                                    :thumbnail => @params.has_key?(:thumbnail),
                                                                    :rotate => @params[:rotate] }
    end
  end

Methods

show  

Included Modules

::BinaryMethods

Public Instance methods

[Source]

    # File components/mw/image_component_controller.rb, line 34
34:   def show
35:     @image = Document.find(@params[:image])
36:     @headers['Date'] = Time.now.rfc822
37:     @headers['Expires'] = (Time.now + 3600).rfc822
38:     @headers['Last-Modified'] = (@image.changed || Time.now).rfc822
39:     @headers['Cache-Control'] = "public, max-age=3600"
40:     if @params[:thumbnail]
41:       filename = filename_for(@image, @image.thumbnail.content_type, true)
42:       render_inline(@image.thumbnail.data, @image.thumbnail.content_type, filename)
43:     else
44:       filename = filename_for(@image, @image.content_type)
45:       data = nil
46:       if @params[:limit_size]
47:         @headers['Last-Modified'] = Time.now.rfc822
48:         img = @image.limit(@params[:limit_size].to_i)
49:         unless @params[:rotate]
50:           data = img.to_blob
51:         else
52:           data = img.rotate(@params[:rotate].to_i).to_blob
53:         end
54:       end
55:       render_inline(data || @image.data, @image.content_type, filename)
56:     end
57:   end

[Validate]