灯箱显示目录中的多个图像 [英] Lightbox display multiple images from directory

查看:134
本文介绍了灯箱显示目录中的多个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 />'; } ?>

这是我的测试页: http://knowledgeoverfame.com/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()

这篇关于灯箱显示目录中的多个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆