Javascript 使用fancybox显示原始图像

Javascript 使用fancybox显示原始图像,javascript,jquery,fancybox,lightbox,fancybox-2,Javascript,Jquery,Fancybox,Lightbox,Fancybox 2,我想使用fancybox在弹出窗口中显示原始图像,但它似乎不起作用。相反,它正在调整图像和容器的宽度和高度 这就是我正在做的: $("a.fancybox").fancybox({ padding : 0, height : $(this).attr('data-height'), width : $(this).attr('data-height'), autoDimensions: false }); 我的链接: <a href="/system/creative

我想使用fancybox在弹出窗口中显示原始图像,但它似乎不起作用。相反,它正在调整图像和容器的宽度和高度

这就是我正在做的:

$("a.fancybox").fancybox({
  padding : 0,
  height : $(this).attr('data-height'),
  width : $(this).attr('data-height'),
  autoDimensions: false
});  
我的链接:

<a href="/system/creatives/images/000/000/008/original/new_creative_form.png?1402035793" data-width="1366" data-height="768" class="fancybox">
<img src="/system/creatives/images/000/000/008/thumb/new_creative_form.png?1402035793" class="img-responsive" alt="New creative form">
</a>


知道我该怎么做吗?

要查看图像的原始大小,只需将
fitoview
设置为
false
如下:

$(".fancybox").fancybox({
    fitToView: false
});
请参见

另一方面,如果要操作通过
数据
属性传递的特定维度,则使用
beforeShow
回调,如:

$(".fancybox").fancybox({
    fitToView: false,
    beforeShow: function () {
        this.width = this.element.data("width");
        this.height = this.element.data("height");
    }
});
请参见

注意我们仍然需要
fitToView:false

重要


这是针对fancyBox v2.1.5的,请确保下载要更新的。

您是否尝试过不提供
宽度
高度
参数?@Rorymcrossan是的,它仍然会调整图像大小。要使用fancyBox v2.1.5。。我们需要购买它作商业用途。是吗?@SachinPrasad:fancyboxv2.x所有的商业网站都需要许可证,但你可以在个人或非营利网站上免费使用。了解更多