Sha256: 662a3b898e1652ed745e593de5c8b5838ffd480c0a31891aab4018ea7fa48ee7
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
module RetinaRails module CarrierWave extend ActiveSupport::Concern included do ## Define retina version based on defined versions in the uploader class versions.each do |v| processor = nil ## Check if there's a resize processor to get the dimensions v[1][:uploader].processors.each do |p| processor = p if p[0].to_s.scan(/resize_to_fill|resize_to_limit|resize_to_fit|resize_and_pad/).any? end ## Define a retina version if processor is present if processor options = processor[1].dup width = options[0] * 2 height = options[1] * 2 2.times { options.delete_at(0) } options.insert(0, height) options.insert(0, width) version "#{v[0]}_retina" do process processor[0] => options end end end end ## Set the correct filename for storage according to the convention (append @2x to filename) def full_filename(for_file) super.tap do |file_name| file_name.gsub!('.', '@2x.').gsub!('retina_', '') if version_name.to_s.include?('retina') end end end end
Version data entries
4 entries across 4 versions & 1 rubygems