开发者_C百科I have big problem with displaying images in fancybox.
Images are "generated" by PHP with header()
and readfile()
.
When I access script directly from browser everything is ok, but when request comes from fancybox JavaScript suddenly browser stop responding and after long time in load content area I get binary code instead of image.
Here is the code:
ob_clean();
header('Content-Type: '.$post->post_mime_type);
$name = basename($post->guid);
$base = home_url();
$path= $_SERVER{'DOCUMENT_ROOT'}.str_replace($base,'',$post->guid);
header ('Content-Disposition: inline; filename='.$name);
header ('Content-length: ' .filesize($path));
readfile($path);
Screen of content loaded into fancybox: http://img502.imageshack.us/img502/8535/screenq.png
The first 4 bytes of the output looks like a valid PNG header.
Please verify that $post->post_mime_type is "image/png".
I don't know the framework, it could get confused by the uncommon "Content-Disposition: inline" header, please delete that line.
Found this on http://fancybox.net/faq
FancyBox gueses content type from url but sometimes it can be wrong. The solution is to force >your type, like so - $(".selector").fancybox({'type' : 'image'}); (required version 1.3+)
精彩评论