灯箱显示目录中的多个图像

编程入门 行业动态 更新时间:2024-10-22 18:39:51
本文介绍了灯箱显示目录中的多个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我无法在网络上的任何地方找到答案(有效)。

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

更多推荐

灯箱显示目录中的多个图像

本文发布于:2023-11-02 08:19:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551869.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   灯箱   图像   目录中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!