Javascript 将另一个文件中具有特定id的元素添加到data layer=galleria
我正在尝试用Galleria创建一个幻灯片,用覆盖层或html层在图像上显示文本。但我有很多页面,它们将被加载,所以它应该是动态的,这就是你所说的吗?覆盖文本应根据galleria将从中加载的文件夹进行更改 这是我的代码,可以根据文件夹的不同动态加载图像Javascript 将另一个文件中具有特定id的元素添加到data layer=galleria,javascript,php,jquery,glob,galleria,Javascript,Php,Jquery,Glob,Galleria,我正在尝试用Galleria创建一个幻灯片,用覆盖层或html层在图像上显示文本。但我有很多页面,它们将被加载,所以它应该是动态的,这就是你所说的吗?覆盖文本应根据galleria将从中加载的文件夹进行更改 这是我的代码,可以根据文件夹的不同动态加载图像 <div class="galleria"> <?php //path to directory to scan $directory = "./"; //get all image files with a .jpg e
<div class="galleria">
<?php
//path to directory to scan
$directory = "./";
//get all image files with a .jpg extension.
$images = glob($directory . "*.jpg");
//print each file name
foreach($images as $image) {
echo "<img src=\"$image\">";
}
?>
</div>
<script>
Galleria.loadTheme('/galleria/themes/classic/galleria.classic.min.js');
Galleria.configure({
showCounter: false,
})
Galleria.run('.galleria');
</script>
我认为这可能是一个解决办法,但无法付诸实施
<div class="galleria">
<?php
//path to directory to scan
$directory = "./";
//get all image files with a .jpg extension.
$images = glob($directory . "*.jpg");
//path to index file with needed text
$meas = glob($directory . "*.php");
//print each file name
foreach($images as $image) {
echo "<img src=\"$image\"";
echo " data-layer=\"$meas\">"; //only see "Array" written over the image
}
?>
</div>
<script>
Galleria.loadTheme('/galleria/themes/classic/galleria.classic.min.js');
Galleria.configure({
showCounter: false,
})
Galleria.run('.galleria');
</script>
希望有人能帮助我,如果需要我可以提供更多的信息。
提前谢谢
亲切问候,,
斯蒂芬
试试这个:
echo " data-layer=".$meas.">"; //only see "Array" written over the image
嗯,,
运输署
echo " data-layer=".$meas.">"; //only see "Array" written over the image