I am looking for a way to generate thumbnails of my uploaded images on the fly. I have a product model that looks kind of like this:

    class Product
      include Mongoid::Document
      include Mongoid::Paperclip

      has_mongoid_attached_file :picture
    end

I basically just want to upload one high-res picture, which I can then use for thumbnails, the main image and also the high-res picture for fancy-box etc..

Is there an easy way to do this?

1 Answers

1
Phyo Wai Win On

There are many attributes you can set for paperclip attached_file.

e.g.,

has_mongoid_attached_file :picture,
    :styles => {
      :original => ['1920x1680>', :jpg],
      :small    => ['100x100#',   :jpg],
      :medium   => ['250x250',    :jpg],
      :large    => ['500x500>',   :jpg]
    }

You can set the :styles attributes with many versions of the image with the sizes and formats you want.

Check here for more details. You do need image processor like RMagick / Imagemagick though.