2011-08-31 102 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