我无法在网络上的任何地方找到答案(有效)。
I can not find an answer(that works) to this anywhere on the web.
我试图让Lightbox从目录中加载图像,因为它们会经常更新。
I am trying to get Lightbox to load images from a directory as they will be frequently updated.
如果有人能够纠正我做错了什么,或者有一个解决方案使用PHP或隐藏div由特定目录自动填充它将是非常感谢。
If anyone can correct what I'm doing wrong, or has a solution using either PHP or a hidden div populated automatically by a specific directory it would be greatly appreciated.
这是我提出的但似乎不起作用;
Here is what I have come up with but is not seeming to work;
<?php $dirname = "img/love/"; $images = glob($dirname."*.jpg"); foreach($images as $image) { echo '<img data-lightbox="love" src="'.$image.'" /><br />'; } ?>这是我的测试页: knowledgeoverfame/tslp/leet/alt/index.html
我在这里没有找到任何类似的问题,但是如果我可能错过了它,请赐教:)
I didn't find any similar questions here with an answer to this but if i may have missed it please enlighten me :)
谢谢!
推荐答案尝试使用 scandir()获取图像文件数组。
Try using scandir() to get an array of your image files.
示例:
<?php $images = scandir($your_folder); foreach ( $images as $key => $filename ) { if ( $key > 1 ) { //ignores the first two values which refer to the current and parent directory echo '<img data-lightbox="love" src="'.$your_folder."/".$filename.'" /><br />'; } } ?>供参考: PHP scandir()
更多推荐
灯箱显示目录中的多个图像
发布评论