为了在我的网站上显示全尺寸图像,我决定使用 Jquery.colorbox ,此插件适用于静态图像位置,例如:
<a rel="ex1" href="http://www.blah.com/image.jpg"><img src="http://www.blah.com/image_thumb.jpg"/></a>
但是当我想使用二进制读/写从目录中获取图像时,这个插件向我显示垃圾数据而不是编译后的 jpg/图像,如下所示:
<a rel="ex1" href="http://www.blah.com/getimage.aspx?id=1234"><img src="http://www.blah.com/getimage.aspx?id=1234"/></a>
这是我获取动态图像的代码片段:
thumbLocation = DataHelper.GetItemPicture(recordID);
using (FileStream IMG = new FileStream(thumbLocation, FileMode.Open))
{
//FileStream IMG = new FileStream(thumbLocation, FileMode.Open);
byte[] buffer = new byte[IMG.Length];
IMG.Read(buffer, 0, (int)IMG.Length);
Response.Clear();
Response.ContentType = "image/JPEG";
Response.AddHeader("Content-Length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
Response.End();}
我该如何解决这个问题?
最佳答案
使用 colorbox 的 photo 属性。示例:
$('a.example').colorbox({photo:true});
原因是 colorbox 用于自动检测图像 URL 的正则表达式对于那种 URL(不包含图像类型扩展名)将失败。
关于c# - 使用通过 Aspx 读取的 Jquery colorbox 和动态图像时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5849648/