custom icon for msoffice

This commit is contained in:
Rueshyna 2013-01-02 17:35:21 +08:00
parent 5f7453c3fb
commit f67664df29
1 changed files with 9 additions and 5 deletions

View File

@ -37,15 +37,19 @@ module Panel::Announcement::BackEnd::BulletinsHelper
end
def file_picture_preview_setting(file_path)
res= ""
#ext = File.extname(file_path)
ext = MIME::Types.type_for(file_path).first.to_s.split("/")[1]
ext = File.extname(file_path)[1..-1].downcase
unless file_path.nil?
case ext
when "jpg","jpeg","png","gif"
{"data-content" => "#{image_tag file_path}" }
when "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx"
{"data-content" => "#{image_tag("http://#{request.host_with_port}/assets/ft-icons/#{ext}/#{ext}-48_32.png")}"}
when "pdf", "zip", "rar"
{"data-content" => "#{image_tag("http://#{request.host_with_port}/assets/ft-icons/#{ext}/#{ext}-64_32.png")}"}
when "doc", "docx"
{"data-content" => "#{image_tag("http://#{request.host_with_port}/assets/ft-icons/docx_mac/docx_mac-64_32.png")}"}
when "xls", "xlsx"
{"data-content" => "#{image_tag("http://#{request.host_with_port}/assets/ft-icons/xlsx_mac/xlsx_mac-64_32.png")}"}
when "ppt", "pptx"
{"data-content" => "#{image_tag("http://#{request.host_with_port}/assets/ft-icons/pptx_mac/pptx_mac-64_32.png")}"}
else
{"data-content" => t("sys.not_previewable") }
end