Sha256: 485ab85199c63b8e167cf780766add058916744da77b0e9c9dbf911498feea58

Contents?: true

Size: 859 Bytes

Versions: 10

Compression:

Stored size: 859 Bytes

Contents

# encoding: utf-8
module Kuhsaft
  class ImageBrickImageUploader < CarrierWave::Uploader::Base
    include CarrierWave::MiniMagick

    storage :file

    def store_dir
      model_identifier = model.class.name.underscore.gsub(/^kuhsaft/, 'cms')
      "uploads/#{model_identifier}/#{mounted_as}/#{model.id}/#{version_name}"
    end

    def full_filename(for_file)
      File.basename for_file
    end

    version :converted do
      process :process_brick_image_size
    end

    version :thumb, from_version: :converted do
      process resize_to_fill: [160, 90]
    end

    def extension_white_list
      %w(jpg jpeg gif png)
    end

    def process_brick_image_size
      image_size = Kuhsaft::ImageSize.find_by_name(model.image_size)
      if image_size.present?
        resize_to_fill(image_size.width, image_size.height)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kuhsaft-2.4.2 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.4.1 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.4.0 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.3.6 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.3.5 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.3.4 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.3.3 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.3.2 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.3.1 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.3.0 app/uploaders/kuhsaft/image_brick_image_uploader.rb