Sha256: a767b32f0c732750e4678ee93a03c91cc028eac3dc6210da905c576a2034ade8
Contents?: true
Size: 1.3 KB
Versions: 9
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module Archangel ## # Application base uploader # class ApplicationUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick ## # Storage path # # @return [String] path for file uploads # def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end ## # Base URL where uploaded files as accessed # # @return [String] base URL for file # def default_url ActionController::Base.helpers.asset_path(default_path) end ## # Uploaded path for file # # @return [String] upload path # def default_path "/images/fallback/" + [version_name, "default.png"].compact.join("_") end ## # File extension whitelist # # @return [Array] file extension whitelist # def extension_whitelist Archangel.config.image_extension_whitelist end ## # Check if file is an image based on file content_type # # @return [Boolean] if file is an image # def image? image_formats.include?(file.content_type) end protected def image_formats %w[image/gif image/jpeg image/jpg image/png] end def image_format?(new_file) image_formats.include?(new_file.content_type) end end end
Version data entries
9 entries across 9 versions & 1 rubygems