Is your plugin hosted on GitHub? Make sure to press the "fetch" button next to the repository field to fetch your plugin's info from GitHub rather than typing it all in.
Repository
Name
Home Page
Short description HasImage is a plugin/gem that allows Ruby on Rails applications to have attached images. It is very small and lightweight: it only requires one column (”has_image_file”) in your model to store the uploaded image’s file name. It was created as a smaller, simpler, lighter alternative to attachment_fu for applications that need to handle uploaded images.
Description <p>HasImage is a plugin/gem that allows Ruby on Rails applications to have attached images. It is very small and lightweight: it only requires one column ("has_image_file") in your model to store the uploaded image's file name. </p> <p>It is, by design, very simplistic: It only supports using a filesystem for storage, and only supports MiniMagick as an image processor. However, its code is very small, clean and hackable, so adding support for other backends or processors should be fairly easy. </p> <p>HasImage works best for sites that want to show image galleries with fixed-size thumbnails. It uses ImageMagick's crop and center gravity functions to produce thumbnails that generally look acceptable, unless the image is a panorama, or the subject matter is close to one of the margins, etc. For most sites where people upload pictures of themselves or their pets the generated thumbnails will look good almost all the time. </p> <p>It's pretty easy to change the image processing / resizing code; you can just override HasImage::Processor#resize_image to do what you wish: </p> <code><pre> module HasImage:: class Processor def resize_image(size) @image.combine_options do |commands| commands.my_custom_resizing_goes_here end end end end </pre></code> <h3>Another image attachment library? Why?</h3> <em>The three chief virtues of a programmer are: Laziness, Impatience and Hubris.</em> - Larry Wall <p>Attachment_fu is too large and general for some of the places I want to use images. I sometimes found myself writing more code to hack attachment_fu than it took to create this gem. In fact, most of the code here has been plucked from my various projects that use attachment_fu. </p> <p>The other image attachment libraries I found fell short of my needs for various other reasons, so I decided to roll my own. </p> <h3>Examples</h3> <h4>Point-and-drool use case:</h4> <p>It's probably not what you want, but it may be useful for bootstrapping. </p> <code><pre> class Member < ActiveRecord::Base has_image end </pre></code> <h4>Single image, no thumbnails, with some size limits:</h4> <code><pre> class Picture < ActiveRecord::Base has_image :resize_to => "200x200", :max_size => 3.megabytes, :min_size => 4.kilobytes end </pre></code> <h4>Image with some thumbnails:</h4> <code><pre> class Photo < ActiveRecord::Base has_image :resize_to => "640x480", :thumbnails => { :square => "200x200", :medium => "320x240" }, :max_size => 3.megabytes, :min_size => 4.kilobytes end </pre></code> <p>HasImage also provides a view helper to make displaying the images extremely simple: </p> <p> <%= image_tag_for(@photo, :thumb => :square) %> </p> <h3>Getting it</h3> <p>Has image can be installed as a gem, or as a Rails plugin. Gem installation is easiest, and recommended: </p> <p> gem install norman-has_image --source http://gems.github.com </p> <p>and add </p> require 'has_image' <p>to your environment.rb file. </p> <p>Alternatively, you can install it as a Rails plugin: </p> <p> ./script plugin install git://github.com/norman/has_image.git </p> <p>Rails versions before 2.1 do not support plugin installation using Git, so if you're on 2.0 (or earlier), then please install the gem rather than the plugin. </p> <p>Then, make sure the model has a column named "has_image_file." </p> <h3>Git repository:</h3> <p> git://github.com/norman/has_image.git </p> <h3>Hacking it</h3> <p>Don't like the way it makes images? Want to pipe the images through <a href="http://eigenclass.org/hiki/seam-carving-in-ocaml">some crazy fast seam carving library written in OCaml</a>, or watermark them with your corporate logo? Happiness is just a <a href="http://en.wikipedia.org/wiki/Monkey_patch">monkey-patch</a> away: </p> <code><pre> module HasImage class Processor def resize_image(size) # your new-and-improved thumbnailer code goes here. end end end </pre></code> <p>HasImage follows a philosophy of "<a href="http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model">skinny model, fat plugin</a>." This means that it tries to pollute your ActiveRecord model with as little functionality as possible, so that in a sense, the model is acts like a "controller" and the plugin like a "model" as regards the image handling functionality. This makes it easier to test, hack, and reuse, because the storage and processing functionality is largely independent of your model, and of Rails. </p> <p>My goal for HasImage is to keep it very small. If you need <strong>a lot</strong> of functionality that's not here, instead of patching this code, you will likely be better off using attachment_fu, which is much more powerful, but also more complex. </p> <h3>Bugs</h3> <p>Please report them on <a href="http://randomba.lighthouseapp.com/projects/14674-has_image">Lighthouse</a>. </p> <p>At the time of writing (July 2008), HasImage is in its infancy. Your patches, bug reports and withering criticism are more than welcome.</p>
Description format RDoc MarkDown Textile
License Ruby's Rails' (MIT) GPL LGPL BSD Apache Artistic PublicDomain BSD-type Free-Trial Free-but-Restricted OpenSource Proprietary Shareware Source-available-proprietary Commercial
Category Assets Controllers Internationalization Misc. Enhancements Model Rails Engines Searching and Queries Security Statistics and Logs Testing View Extensions