Sha256: d76d837544136a3e3c3da36f7db70750c3e45f0c404e862ed9d5d7a38d290a3c

Contents?: true

Size: 603 Bytes

Versions: 9

Compression:

Stored size: 603 Bytes

Contents

require 'carrierwave/processing/mini_magick'

module Thredded
  class AttachmentUploader < CarrierWave::Uploader::Base
    include CarrierWave::MiniMagick
    storage :file

    def store_dir
      "uploads/#{mounted_as}/#{model.id}"
    end

    version :thumb, if: :image? do
      process :resize_to_fit => [90, 90]
    end

    version :mobile, if: :image? do
      process :resize_to_limit => [480, 2000]
    end

    def extension_white_list
      %w(jpg jpeg gif png pdf zip tgz txt)
    end

    protected

    def image?(new_file)
      new_file.content_type.include? 'image'
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
thredded-0.0.10 app/uploaders/thredded/attachment_uploader.rb
thredded-0.0.9 app/uploaders/thredded/attachment_uploader.rb
thredded-0.0.8 app/uploaders/thredded/attachment_uploader.rb
thredded-0.0.7 app/uploaders/thredded/attachment_uploader.rb
thredded-0.0.6 app/uploaders/thredded/attachment_uploader.rb
thredded-0.0.5 app/uploaders/thredded/attachment_uploader.rb
thredded-0.0.4 app/uploaders/thredded/attachment_uploader.rb
thredded-0.0.3 app/uploaders/thredded/attachment_uploader.rb
thredded-0.0.1 app/uploaders/thredded/attachment_uploader.rb