Sha256: 057aead43b2aa4b68a519d48cc2d4c0b3745907de487a5ce756b9f3b40d4c50b

Contents?: true

Size: 858 Bytes

Versions: 9

Compression:

Stored size: 858 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)
      return unless image_size.present?
      resize_to_fill(image_size.width, image_size.height)
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
kuhsaft-2.6.3 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.6.2 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.6.1 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.5.2 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.6.0 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.5.1 app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.5.0 app/uploaders/kuhsaft/image_brick_image_uploader.rb
qbrick-2.5.0.pre app/uploaders/kuhsaft/image_brick_image_uploader.rb
kuhsaft-2.4.3 app/uploaders/kuhsaft/image_brick_image_uploader.rb