Add video storing into image uploader


Is it possible to save videos and images with one uploader?

Currently, I have an image uploader and have to modify it for videos too.

require 'image_processing/mini_magick'

class FeedbackPhotoUploader < Shrine
  include ImageProcessing::MiniMagick

  ALLOWED_TYPES = %w[image/jpeg image/png image/gif]
  MAX_SIZE      = (30 * 1024 * 1024)

  plugin :upload_endpoint, max_size: MAX_SIZE
  plugin :add_metadata

  plugin :processing
  plugin :delete_promoted
  plugin :versions

  plugin :determine_mime_type
  plugin :store_dimensions, analyzer: :mini_magick
  plugin :validation_helpers

  plugin :remove_attachment
  plugin :pretty_location

  Attacher.validate do
    validate_max_size MAX_SIZE
    if validate_mime_type_inclusion(ALLOWED_TYPES)
      validate_max_width 6000
      validate_max_height 6000

  process(:store) do |io, context|
    versions = { original: io }
    record   = context[:record] do |original|
      pipeline = ImageProcessing::MiniMagick.source(original)

      versions[:big] = pipeline.resize_to_fit!(960 , 600)
      versions[:thumb]  = pipeline.resize_to_fit!(300, 167)
  rescue StandardError => e
    AppLogger.logger.error "#{self.class} processing error: #{e.message}" e.backtrace.inspect
#shrine version
shrine 2.19.4

It would be great to save a video preview as an image for using it later as


Yes, it should be possible. Most of Shrine plugins are designed to support storing multiple types of files using the same uploader. If some lack necessary flexibility, I would definitely be open to improving them.