diff --git a/app/models/album.rb b/app/models/album.rb index b0a435f..84b8b2c 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -15,6 +15,7 @@ class Album field :order, type: Integer, default: -1 field :min_order, type: Integer, default: -1 field :resize_gravity + field :thumb_process_option, type: Integer, default: 0 # has_and_belongs_to_many :tags, :class_name => "GalleryTag" has_many :album_images, :autosave => true, :dependent => :destroy has_many :album_colors, :autosave => true, :dependent => :destroy diff --git a/app/uploaders/gallery_uploader.rb b/app/uploaders/gallery_uploader.rb index d4cb222..eaef6b3 100644 --- a/app/uploaders/gallery_uploader.rb +++ b/app/uploaders/gallery_uploader.rb @@ -13,7 +13,7 @@ class GalleryUploader < CarrierWave::Uploader::Base # Include RMagick or ImageScience support: # include CarrierWave::RMagick # include CarrierWave::ImageScience - include CarrierWave::MiniMagick + include CarrierWave::MiniMagick # Choose what kind of storage to use for this uploader: # storage :file # storage :s3 @@ -68,11 +68,11 @@ class GalleryUploader < CarrierWave::Uploader::Base end version :thumb do process :convert => 'png', :if => :transparent? - process :pad_process => [200,200] + process :thumb_process => [200, 200] end version :thumb_large do process :convert => 'png', :if => :transparent? - process :pad_process => [600,600] + process :thumb_process => [600, 600] end version :theater do process :limit_process => [1920, 1080] @@ -175,9 +175,14 @@ class GalleryUploader < CarrierWave::Uploader::Base now_album = model.album now_album.album_colors.first['color']=='transparent' rescue true end - def pad_process (w,h) + def thumb_process(w,h) now_album = model.album - resize_and_pad(w, h, (transparent? ? :transparent : now_album.album_colors.first['color']), (now_album.resize_gravity rescue 'Center')) + case now_album.thumb_process_option + when 0 + resize_and_pad(w, h, (transparent? ? :transparent : now_album.album_colors.first['color']), (now_album.resize_gravity rescue 'Center')) + when 1 + limit_process(w, h) + end end end diff --git a/app/views/admin/galleries/_form.html.erb b/app/views/admin/galleries/_form.html.erb index 2c734c5..7283f6a 100644 --- a/app/views/admin/galleries/_form.html.erb +++ b/app/views/admin/galleries/_form.html.erb @@ -59,7 +59,11 @@ input.minicolors-input{ } }) return true - }) + }); + $('#album_thumb_process_option').change(function(){ + $('.thumb_process_option').hide(); + $('.thumb_process_option'+'.'+$(this).val()).show(); + }).trigger('change'); });