【问题标题】:Strange chars on ColorBox on image from Webapi来自 Webapi 的图像上 ColorBox 上的奇怪字符
【发布时间】:2014-03-25 17:36:56
【问题描述】:

我正在使用 jquery colorbox 插件创建一个图像库,对于图像我使用 asp.net webapi 来操作大小和裁剪。

当我单击缩略图时出现问题,打开的框不显示我想要的图像,但框内有很多奇怪的字符,因为我加载的是平面文本文件而不是图像。

知道我做错了什么吗?

代码如下:

<a class="gal_4" href="/api/CDN/GaleryImage/25" rel="image"><img src="/api/CDN/GaleryThumbnail/25" alt="" /></a>
<script>
    $(function () {

        $(".gal_4").colorbox({ rel: 'gal_4' });

    });
</script>

对于生成返回图像的 webapi:

HttpResponseMessage rv = new HttpResponseMessage(HttpStatusCode.OK);
MemoryStream oMS;

... Load image byte array on Memory stream ...

rv.Content = new ByteArrayContent(oMS.ToArray());
rv.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpg");

return rv;

当我在我的 html 中指向图像标签的 src 属性时,它工作得非常好,但不是与颜色框,有什么想法吗?

提前感谢您的帮助

【问题讨论】:

    标签: jquery colorbox asp.net-web-api


    【解决方案1】:

    尝试使用photo 属性

    If true, this setting forces Colorbox to display a link as a photo. Use this when automatic photo detection fails (such as using a url like 'photo.php' instead of 'photo.jpg')

    类似问题:Problem while working with Jquery colorbox and dynamic images that reading via Aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-24
      • 2011-03-30
      • 1970-01-01
      • 1970-01-01
      • 2011-01-17
      相关资源
      最近更新 更多