2011-08-31 55 views
0

這裏是當我有絕對的URL加載圖像會發生什麼: http://dl.dropbox.com/u/331982/Help/Screen%20shot%202011-08-31%20at%2011.17.44%20AM%20copy.pngRuby on Rails的+回形針+ Facebox:圖像加載文本,而不是圖像

是什麼原因造成不被呈現爲圖像的圖像?

這是Facebox的問題嗎?

這是我做圖片鏈接:

<a href="images/stairs.jpg" rel="facebox">text</a> 

就像在網站上http://defunkt.io/facebox/

下載方法:

def download 
    head(:not_found) and return if (media = Media.find_by_id(params[:id])).nil? 

    path = media.document.path(params[:style]) 
    head(:bad_request) and return unless File.exist?(path) && params[:format].to_s == File.extname(path).gsub(/^\.+/, '') 

    send_file_options = { :disposition => 'inline', :type => media.document.content_type } 
    send_file_options = { :disposition => 'inline' } if File.extname(path) == ".swf" && media.document_content_type == "application/x-shockwave-flash" 

    case SEND_FILE_METHOD 
     when :apache then send_file_options[:x_sendfile] = true 
     when :nginx then head(:x_accel_redirect => path.gsub(Rails.root, ''), :content_type => send_file_options[:type]) and return 
    end 

    send_file(path, send_file_options) 
    end 

回答

0

這看起來像一個MIME類型的錯誤,在這裏你將它作爲HTML返回,或者將其解釋爲HTML。如果您使用的是send_file,請務必設置您的響應MIME類型。這是send_file:type選項。

+0

應該:type be? – NullVoxPopuli

+0

它目前設置爲::type => media.document.content_type – NullVoxPopuli

+0

我只是添加我的下載方法... – NullVoxPopuli