Ruby on rails RubyonRails+;回形针&x2B;Facebox:图像作为文本而不是图像加载

Ruby on rails RubyonRails+;回形针&x2B;Facebox:图像作为文本而不是图像加载,ruby-on-rails,paperclip,facebox,Ruby On Rails,Paperclip,Facebox,下面是加载带有绝对URL的图像时发生的情况: 是什么导致图像无法渲染为图像 这是Facebox的问题吗 这是我制作图像链接的方式: <a href="images/stairs.jpg" rel="facebox">text</a> 这看起来像是一个MIME类型的错误,您将其返回为HTML或解释为HTML的内容。如果使用的是send_file,请确保设置响应MIME类型。这是:键入发送文件的选项您需要使用以下修补程序修补facebox.js Facebox不处理ra

下面是加载带有绝对URL的图像时发生的情况:

是什么导致图像无法渲染为图像

这是Facebox的问题吗

这是我制作图像链接的方式:

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

这看起来像是一个MIME类型的错误,您将其返回为HTML或解释为HTML的内容。如果使用的是
send_file
,请确保设置响应MIME类型。这是
:键入
发送文件的
选项

您需要使用以下修补程序修补facebox.js


Facebox不处理rails附加到图像的URL查询参数。

它当前设置为::type=>media.document.content\u type请确保它设置为某个值。检查的一个好方法是使用命令行工具
curl-I
,它将向您显示它收到的标题。PNG图像应该是
image/PNG
  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