我试着在我的页面上做简单的画廊。当打开web的gallery部分时,只有一些由src和href标签显示的图片:
echo '<div style="float:left; margin:5px;">
<a href="'.$link.'"><img src="'.$mini.'" title="clickclack.cz" alt="clickclack.cz" style="height:171px; border:2px solid black;" /></a>
</div>';现在-当我点击其中的一些图片时,我不想简单地在白色背景上显示全尺寸的图片。我想在Galleria插件中打开它,并有可能滚动到该页面上的其他图像。我想不出该怎么做。如果我在<div id="galleria" style="height:500px;">中用图片包装div,当我打开图片库部分时,插件就会立即启动。
JS部分代码非常基础:
$(function() {
Galleria.loadTheme('galleria/themes/classic/galleria.classic.min.js');
Galleria.run('#galleria');
});编辑:我找到了一个解决方案。根据PHP条件,首先我将href参数设置为href="?galerie&inGallery&index='.$i.'"。galerie参数只表示打开同一页,索引是while cycle中的行数(它与Galleria中的索引匹配),inGallery设置PHP条件。使用URL中的href参数,包含图片的块现在被包装在<div id="galleria">中,href参数是指向图像的实际链接。现在画廊页面已经在Galleria中打开了。为了在点击的图片上打开Galleria,我添加了JS函数。我的JS部分(也包装在条件全屏中)现在看起来像这样(加上我添加了带有id="fullscreen“的链接以切换全屏):
function GetURLParameter(sParam){
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++){
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam){
return sParameterName[1];
}
}
}
$(function() {
var index = GetURLParameter('index');
Galleria.loadTheme('galleria/themes/classic/galleria.classic.min.js');
Galleria.run('#galleria', { show: index });
$('#fullscreen').click(function() {
$('#galleria').data('galleria').toggleFullscreen(); // toggles the fullscreen
});
});发布于 2015-03-31 03:47:24
您需要使用show method。From the link“显示指定为索引的图像。您可以随时调用此方法,图像将被置于转换队列中。”
https://stackoverflow.com/questions/21897660
复制相似问题