Commit 8925ef9ab8c32d0abdc9c191564e9c8d4fb66ed0

Authored by Braulio Bhavamitra
1 parent f231e19b

rails4: Select RMagick processor for attachment_fu

app/models/image.rb
... ... @@ -6,8 +6,8 @@ class Image < ActiveRecord::Base
6 6  
7 7 sanitize_filename
8 8  
9   - has_attachment :content_type => :image,
10   - :storage => :file_system,
  9 + has_attachment :content_type => :image,
  10 + :storage => :file_system,
11 11 :path_prefix => 'public/image_uploads',
12 12 :resize_to => '800x600>',
13 13 :thumbnails => { :big => '150x150',
... ... @@ -15,7 +15,8 @@ class Image < ActiveRecord::Base
15 15 :portrait => '64x64',
16 16 :minor => '50x50>',
17 17 :icon => '20x20!' },
18   - :max_size => 5.megabytes # remember to update validate message below
  18 + :max_size => 5.megabytes, # remember to update validate message below
  19 + processor: 'Rmagick'
19 20  
20 21 validates_attachment :size => N_("{fn} of uploaded file was larger than the maximum size of 5.0 MB").fix_i18n
21 22  
... ...
app/models/reported_image.rb
... ... @@ -5,6 +5,7 @@ class ReportedImage < ActiveRecord::Base
5 5  
6 6 has_attachment :content_type => :image,
7 7 :storage => :file_system,
8   - :max_size => 5.megabytes
  8 + :max_size => 5.megabytes,
  9 + processor: 'Rmagick'
9 10  
10 11 end
... ...
app/models/thumbnail.rb
1 1 class Thumbnail < ActiveRecord::Base
2 2 has_attachment :storage => :file_system,
3   - :content_type => :image, :max_size => 5.megabytes
  3 + :content_type => :image, :max_size => 5.megabytes, processor: 'Rmagick'
4 4 validates_as_attachment
5 5  
6 6 sanitize_filename
... ...
app/models/uploaded_file.rb
... ... @@ -63,7 +63,8 @@ class UploadedFile &lt; Article
63 63 has_attachment :storage => :file_system,
64 64 :thumbnails => { :icon => [24,24], :bigicon => [50,50], :thumb => '130x130>', :slideshow => '320x240>', :display => '640X480>' },
65 65 :thumbnail_class => Thumbnail,
66   - :max_size => self.max_size
  66 + :max_size => self.max_size,
  67 + processor: 'Rmagick'
67 68  
68 69 validates_attachment :size => N_("{fn} of uploaded file was larger than the maximum size of %{size}").sub('%{size}', self.max_size.to_humanreadable).fix_i18n
69 70  
... ...
config/initializers/attachment_fu.rb 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +Technoweenie::AttachmentFu.mattr_writer :default_processors
  2 +Technoweenie::AttachmentFu.default_processors = %w(Rmagick ImageScience MiniMagick Gd2 CoreImage)
... ...