0
@@ -38,21 +38,24 @@ module HasImage
0
# * :resize_to => "200x200",
0
+ # * :auto_generate_thumbnails => true,
0
# * :max_size => 12.megabytes,
0
# * :min_size => 4.kilobytes,
0
- # * :path_prefix => klass.t
o_s.tableize,
0
+ # * :path_prefix => klass.t
able_name,
0
# * :base_path => File.join(RAILS_ROOT, 'public'),
0
# * :column => :has_image_file,
0
# * :convert_to => "JPEG",
0
# * :output_quality => "85",
0
# * :invalid_image_message => "Can't process the image.",
0
# * :image_too_small_message => "The image is too small.",
0
- # * :image_too_big_message => "The image is too big."
,0
+ # * :image_too_big_message => "The image is too big."
0
def default_options_for(klass)
0
:resize_to => "200x200",
0
:auto_generate_thumbnails => true,
0
:max_size => 12.megabytes,
0
:min_size => 4.kilobytes,
0
:path_prefix => klass.table_name,
0
@@ -75,17 +78,19 @@ module HasImage
0
# The different setting options are described below.
0
- # * <tt>:resize_to</tt> - Dimensions to resize to. This should be an ImageMagick {geometry string}[http://www.imagemagick.org/script/command-line-options.php#resize]. Fixed sizes are recommended.
0
- # * <tt>:thumbnails</tt> - A hash of thumbnail names and dimensions. The dimensions should be ImageMagick {geometry strings}[http://www.imagemagick.org/script/command-line-options.php#resize]. Fixed sized are recommended.
0
- # * <tt>:min_size</tt> - Minimum file size allowed. It's recommended that you set this size in kilobytes.
0
- # * <tt>:max_size</tt> - Maximum file size allowed. It's recommended that you set this size in megabytes.
0
- # * <tt>:base_path</tt> - Where to install the images. You should probably leave this alone, except for tests.
0
- # * <tt>:path_prefix</tt> - Where to install the images, relative to basepath. You should probably leave this alone.
0
- # * <tt>:convert_to</tt> - An ImageMagick format to convert images to. Recommended formats: JPEG, PNG, GIF.
0
- # * <tt>:output_quality</tt> - Image output quality passed to ImageMagick.
0
- # * <tt>:invalid_image_message</tt> - The message that will be shown when the image data can't be processed.
0
- # * <tt>:image_too_small_message</tt> - 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.
0
- # * <tt>:image_too_big_message</tt> - 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.
0
+ # * +:resize_to+ - Dimensions to resize to. This should be an aImageMagick {geometry string}[http://www.imagemagick.org/script/command-line-options.php#resize]. Fixed sizes are recommended.
0
+ # * +:thumbnails</tt> - A hash of thumbnail names and dimensions. The dimensions should be ImageMagick {geometry strings}[http://www.imagemagick.org/script/command-line-options.php#resize]. Fixed sized are recommended.
0
+ # * +: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+
0
+ # * +:delete+ - Flag to indicate if the images should be delete from the storage (e.g. the Filesystem) when the record is destroyed
0
+ # * +:min_size</tt> - Minimum file size allowed. It's recommended that you set this size in kilobytes.
0
+ # * +:max_size</tt> - Maximum file size allowed. It's recommended that you set this size in megabytes.
0
+ # * +:base_path</tt> - Where to install the images. You should probably leave this alone, except for tests.
0
+ # * +:path_prefix</tt> - Where to install the images, relative to basepath. You should probably leave this alone.
0
+ # * +:convert_to</tt> - An ImageMagick format to convert images to. Recommended formats: JPEG, PNG, GIF.
0
+ # * +:output_quality</tt> - Image output quality passed to ImageMagick.
0
+ # * +:invalid_image_message</tt> - The message that will be shown when the image data can't be processed.
0
+ # * +:image_too_small_message</tt> - 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.
0
+ # * +:image_too_big_message</tt> - 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.
0
# has_image # uses all default options
0
@@ -183,7 +188,7 @@ module HasImage
0
# Deletes the image from the storage.
0
- return if send(has_image_options[:column]).blank?
0
+ return if send(has_image_options[:column]).blank?
|| !has_image_options[:delete]0
self.class.transaction do
0
storage.remove_images(self, send(has_image_options[:column]))