Sha256: 408c7b2057ba9a4f36f36061e9d503b7a6561d3a65c9de8da7556db11aa18c3d

Contents?: true

Size: 995 Bytes

Versions: 17

Compression:

Stored size: 995 Bytes

Contents

module Models  
  module Extensions    
    module Asset      
      module Vignette
        
        def vignette_url
          if self.image?
            if self.width < 80 && self.height < 80
              self.source.url
            else
              self.source.url(:medium)
            end
          # elsif asset.pdf?
          #   image_tag(asset.source.url(:medium))
          else
            mime_type_to_url(:medium)
          end
        end
        
        protected
        
        def mime_type_to_url(size)
          mime_type = File.mime_type?(self.source_filename)
          filename = "unknown"

          if !(mime_type =~ /pdf/).nil?
            filename = "PDF"
          elsif !(mime_type =~ /css/).nil?
            filename = "CSS"
          elsif !(mime_type =~ /javascript/).nil?
            filename = "JAVA"
          end

          File.join("admin", "icons", "filetype", size.to_s, filename + ".png")
        end
        
      end      
    end    
  end  
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
locomotive_cms-0.0.3.3 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.3.1 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.2.9 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.2.8 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.2.7 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.2.6 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.2.5 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.2.4 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.2.3 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.2.2 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.2.1 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.2 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.1.4 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.1.3 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.1.2 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.1.1 app/models/extensions/asset/vignette.rb
locomotive_cms-0.0.1 app/models/extensions/asset/vignette.rb