# NO ACTUALIZAR
# Este uploader sólo lo utilizan modelos deprecados
#
class AvatarUploader < CarrierWave::Uploader::Base

  if RbConfig::CONFIG["target_os"] =~ /mswin|mingw|cygwin/i
    include CarrierWave::MiniMagick
  else
    include CarrierWave::RMagick
  end

  storage :file

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

  version :large do
    process :convert => :jpg
    process :fix_exif_rotation
    # process :quality => 75
    process resize_to_fit: [1200, 1200]
    def full_filename (for_file = model.source.file)
      "#{model.id}.jpg"
    end
  end

  def quality(percentage)
    manipulate! do |img|
      img.quality(percentage.to_s)
      img = yield(img) if block_given?
      img
    end
  end

  def fix_exif_rotation
    manipulate! do |img|
      img.tap(&:auto_orient)
    end
  end

end
