Sha256: a244d9f7be890d5fd227253e6e10e43aed01c876682a7699ac0a91ea1877cf8a
Contents?: true
Size: 848 Bytes
Versions: 2
Compression:
Stored size: 848 Bytes
Contents
module RetinaRails::Extensions ## Insert :retina interpolation in url or path def self.optimize_path(path) path.scan(':retina').empty? ? path.gsub(':filename', ':basename.:extension').split('.').insert(-2, ':retina.').join : path end def self.override_default_options ## Remove _retina from style so it doesn't end up in filename Paperclip.interpolates :style do |attachment, style| style.to_s.end_with?('_retina') ? style.to_s[0..-8] : style end ## Replace :retina with @2x if style ends with _retina Paperclip.interpolates :retina do |attachment, style| style.to_s.end_with?('_retina') ? '@2x' : '' end ## Make default url compatible with retina optimzer url = Paperclip::Attachment.default_options[:url] Paperclip::Attachment.default_options[:url] = optimize_path(url) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
retina_rails-0.1.3 | lib/retina_rails/extensions.rb |
retina_rails-0.1.2 | lib/retina_rails/extensions.rb |