code: def attachment(types)
  
        # get all the files that are of the major types passed in
        files = []
  
        types.each do |type|
          media.keys.find_all{|k| type.include?("/") ? k == type : k.index(type) == 0 }.each do |key|
            files += media[key]
          end
        end
        return nil if files.empty?
  
        # set temp holders
        file = nil # explicitly declare the file and size
        size = 0
        mime_type = nil
  
        #get the largest file
        files.each do |path|
          next unless File.exist?(path)
          if File.size(path) > size
            size = File.size(path)
            file = File.new(path)
            media.each do |type,_files|
              mime_type = type if _files.detect{ |_path| _path == path }
            end
          end
        end
  
        return nil if file.nil?
  
        # These singleton methods implement the interface necessary to be used
        # as a drop-in replacement for files uploaded with CGI.rb.
        # This helps if you want to use the files with, for example,
        # attachment_fu.
  
        def file.local_path
          self.path
        end
  
        def file.original_filename
          File.basename(self.path)
        end
  
        def file.size
          File.size(self.path)
        end
  
        # this one is kind of confusing because it needs a closure.
        class << file
          self
        end.send(:define_method, :content_type) { mime_type }
  
        file
      end
docs: used by #default_media and #text to return the biggest attachment type
   listed in the types array