here is what happens when I load an image with an absolute URL: http://dl.dropbox.com/u/331982/Help/Screen%20shot%202011-08-31%20at%2011.17.44%20AM%20copy.png
What is causing the image not to be rendered as an image?
Is it an 开发者_开发知识库issue with Facebox?
This is how I made the image link:
<a href="images/stairs.jpg" rel="facebox">text</a>
Just like on the website http://defunkt.io/facebox/
The download method:
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
This looks like a MIME type error, where you're returning it as HTML or something interpreted as HTML. If you're using send_file
, be sure to set your response MIME type. This is the :type
option for send_file
.
You need to patch facebox.js with the following patch.
https://github.com/ipavelek/facebox/commit/e4a0101596cd269f8337920564c8d33e193e8cbe
Facebox doesn't handle the URL query param that rails appends to images.
精彩评论