Sha256: f4301cd60ab12eedfcb1a8074f8156021c8619ef9f097e5b0bcfa0063919f981

Contents?: true

Size: 854 Bytes

Versions: 16

Compression:

Stored size: 854 Bytes

Contents

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

    storage :file

    def store_dir
      model_identifier = model.class.name.underscore.gsub(/^qbrick/, '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 = Qbrick::ImageSize.find_by_name(model.image_size)
      return unless image_size.present?
      resize_to_fit(image_size.width, image_size.height)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
qbrick-2.7.1 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.7 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.6.10 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.6.9 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.6.8 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.6.7 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.6.6 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.6.5 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.6.4 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.6.3 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.6.2 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.6.1 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.6.0 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.5.2 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.5.1 app/uploaders/qbrick/image_brick_image_uploader.rb
qbrick-2.5.0 app/uploaders/qbrick/image_brick_image_uploader.rb