从另一个文件中添加具有特定id的元素到data-layer= galleria



我正在尝试创建一个幻灯片(与Galleria)与覆盖或"html层"来显示图像上的文本。但是我有很多页面,它将被加载,所以它应该是动态的(你是怎么称呼它的?)覆盖文本应该根据文件夹的变化,画廊将被加载。

这是我的代码,根据文件夹的不同,可以很好地"动态"加载图像。

<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>

我认为gallery -data可能是一个解决方案,但不能让它工作。

<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

HTH,TD

最新更新