Sha256: ce6141521cdf216c2edfdd45abf6eeeb7f1c38e427693775e2a1a627c8bde8f1
Contents?: true
Size: 747 Bytes
Versions: 6
Compression:
Stored size: 747 Bytes
Contents
class ResourceUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick def store_dir "files/#{model.class.to_s.underscore}/#{model.id}" end version :thumb, if: :image? do process dynamic_resize_to_fit: :thumb end version :medium, if: :image? do process dynamic_resize_to_fit: :medium end version :avatar, if: :image? do process dynamic_resize_to_fit: :avatar end def dynamic_resize_to_fit(size) resize_setting = model.blog.send("image_#{size}_size").to_i resize_to_fit(resize_setting, resize_setting) end def image?(new_file) mime_magic_content_type = new_file.send :mime_magic_content_type mime_magic_content_type && mime_magic_content_type.include?('image') end end
Version data entries
6 entries across 6 versions & 1 rubygems