Super Image plugin
Plugin details
Documentation
ruby script/plugin install http://beautifulpixel.textdriven.com/svn/plugins/super_image/
To include a link to an image in your view, first define a route that looks something like this:
map.super_image 'my_images/show_image/:id/:size/image.jpg', :controller => 'my_images', :action => 'my_image_action_for_this_controller'
Then call it form your controller/view with:
<%= image_tag(super_image_url( :id => @img.id, # The id of the image you want to show. :size => '175x100', # The size of the image you want returned. :crop => true # Optional. Will make the returned image exactly the provided size (see below) ), :alt => "Image #{@img.id}") %>
Or simply navigate to "/my_controller_name/my_image_method/1". And to use the size constraint navigate to "/my_controller_name/show_image/1?size=120". You can write custom url routes to make the size parameter prettier if you like.
The "size" parameter is the size of the largest dimension of the image. For example, a 640x480 image is requested with ":size => 100". The image will be rendered at 100x75. Aspect Ratio is always preserved.
":size" can be 2 dimensional as well. A ":size" of "640x320" will make the width no bigger than 640, and the height no bigger than 320. Resizing you 640x480 image to 427x320.
Lastly, you can use the ":crop" option (just pass any value to "crop" in the url, "true" would probably do the job best) to resize the image and crop it to exactly the specified size. Use this when you want to get an image that is exactly the size you ask for.
Remember that SuperImage inherits from ActiveRecord and works just like every other model in Rails. It simply has a small amount of added functionality.
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | Back in time (1 older version) | Last edited by: hardway, about 1 year ago

