Sha256: a63c2fb55d3544574d15127c4c46c5d4021244c2762cb29bbb774c5070101ba0
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 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| processors = v[1][:uploader].processors.dup dimensions_processor = nil ## Check if there's a resize processor to get the dimensions processors.each do |p| dimensions_processor = processors.delete(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 dimensions_processor options = dimensions_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 dimensions_processor[0] => options ## Set other processors processors.each do |processor| process processor[0] => processor[1] end 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
retina_rails-0.0.6 | lib/retina_rails/carrierwave.rb |
retina_rails-0.0.5 | lib/retina_rails/carrierwave.rb |