def extension attachment, style_name
      ((style = attachment.styles[style_name]) && style[:format]) ||
        File.extname(attachment.original_filename).gsub(/^\.+/, "")
    end
def extension attachment, style_name
      ((style = attachment.styles[style_name]) && style[:format]) ||
        File.extname(attachment.original_filename).gsub(/^\.+/, "")
    end
Returns the extension of the file. e.g. "jpg" for "file.jpg"
 If the style has a format defined, it will return the format instead
 of the actual extension.