module RetinaRails module Strategies module Paperclip module Base extend ActiveSupport::Concern module ClassMethods def retina! include Uploader end end end module Uploader extend ActiveSupport::Concern included do ## Override paperclip default options Extensions.override_default_options end module ClassMethods def has_attached_file(name, options={}) super has_attached_retina_file name if options[:retina] end def has_attached_retina_file(name) attachment = attachment_definitions[name] ## Check for style definitions styles = attachment[:styles] retina_options = if attachment[:retina].is_a?(Hash) attachment[:retina] else { :quality => 40 } end ## Get retina quality retina_quality = retina_options[:quality] || 40 if styles retina_styles = {} retina_convert_options = {} convert_options = attachment[:convert_options] ## Iterate over styles and set optimzed dimensions styles.each_pair do |key, value| dimensions = value[0] width = dimensions.scan(/\d+/)[0].to_i * 2 height = dimensions.scan(/\d+/)[1].to_i * 2 processor = dimensions.scan(/#|