Module: HasImage::ClassMethods
- Defined in:
- lib/has_image.rb
Instance Method Summary collapse
-
#has_image(options = {}) ⇒ Object
Options.
Instance Method Details
#has_image(options = {}) ⇒ Object
Options
- :resize_to - Dimensions to resize to. This should be an ImageMagick geometry string. Fixed sizes are recommended.
- :thumbnails - A hash of thumbnail names and dimensions. The dimensions should be ImageMagick geometry strings. Fixed sized are recommended.
- :auto_generate_thumbnails - Flag to indicate whether to automatically generate thumbnails when the image_data changes (e.g. on create). If you set this to false, your application code needs to take care of generating thumbnails, e.g. using
#generate_thumbnail - :delete - Flag to indicate if the images should be deleted from the storage (e.g. the filesystem) when the record is destroyed.
- :min_size - Minimum file size allowed. It's recommended that you set this size in kilobytes.
- :max_size - Maximum file size allowed. It's recommended that you set this size in megabytes.
- :base_path - Where to install the images.
- :path_prefix - Where to install the images, relative to basepath.
- :convert_to - An ImageMagick format to convert images to.
- :output_quality - Image output quality passed to ImageMagick.
- :invalid_image_message - The message that will be shown when the image data can't be processed.
- :image_too_small_message - The message that will be shown when the image file is too small. You should ideally set this to something that tells the user what the minimum is.
- :image_too_big_message - The message that will be shown when the image file is too big. You should ideally set this to something that tells the user what the maximum is.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/has_image.rb', line 169 def has_image( = {}) .assert_valid_keys(HasImage.(self).keys) = HasImage.(self).merge() class_attribute :has_image_options self. = after_create :install_images after_save :update_images after_destroy :remove_images validate :image_data_valid?, :on => :create include ModelInstanceMethods extend ModelClassMethods end |