我有两个插件:Tiles Gallery和 Colorbox - 一个非常基本的图库设置,单击缩略图 -> 在 Colorbox 中加载完整尺寸。但是,我希望能够单击图库图像并在 Colorbox 弹出窗口的 iframe 中加载网页。
以下是常规画廊项目/图像的加载方式(完美运行):
<article class="tile category">
<a href="path/to/image.jpg">
<img class="item" src="path/to/thumbnail.jpg" />
<div class="caption"></div>
</a>
</article>
这是我尝试加载 iframe 失败的原因:
<article class="tile iframe" data-type="html">
<a class="tile iframe" href="http://google.com">
<img class="item" src="path/to/thumbnail.jpg" />
</a>
</article>
这是 jQuery:
<script>
//instantiate Final Tiles Gallery
$("#gallery-name").finalTilesGallery({
minTileWidth: 120,
margin: 1,
});
// colorbox image size setup
$(".tile a").colorbox({rel:'group1', maxWidth:'95%', maxHeight:'95%'
});
// colorbox iframe setup
$(".tile iframe").colorbox({iframe:true, innerWidth:600, innerHeight:700});
</script>
为了让 Tiles gallery 插件工作,每个都必须有一个类“tile something”。根据 Tiles gallery 文档,YouTube 视频使用 iframe 按以下方式加载:
<article id="video" class="tile ftg-set-2" data-type="video">
<iframe class="item" width="540" height="300" src="http://www.youtube.com/embed/M4yCwlDxPtY" frameborder="0" allowfullscreen></iframe>
</article>
但是我不希望 iframe 显示在画廊本身中,我想要一个缩略图图像来引导它并且只在 Colorbox 中显示它。
如果您需要更多信息,请告诉我。任何帮助将不胜感激!
最佳答案
我设法解决了这样的问题:
<article class="tile category">
<a class="className" href="http://iframe-address.com">
<img class="item" src="path/to/thumbnail.jpg" />
<div class="caption"></div>
</a>
</article>
j查询:
$(".className").colorbox({iframe:true, innerWidth:'99%', innerHeight:'99%'});
关于jquery - 单击图像时在 Colorbox 中加载 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16883964/