我想创建一个图像滑块,自动滑动文件夹中的所有相似图像

时间:2011-04-07 18:51:11

标签: php javascript ajax image slider

假设我有一堆基于日期的文件名的图像,如下所示:

URL /图像/ top20110326.png

URL /图像/ top20110327.png

URL /图像/ top20110328.png

URL /图像/ top20110329.png

URL /图像/ top20110330.png

URL /图像/ top20110331.png

URL /图像/ top20110401.png

URL /图像/ top20110402.png

我想找到一些可以提供这些功能的代码或工具或插件:

  1. 在给定图像的所有URL地址的情况下自动加载图像。
  2. 为用户提供一个滑块,以按日期的顺序快速浏览图像
  3. 为用户提供自动滑动图像的选项(没有任何影响,只需将其替换为另一个)。优选地,速度可调。
  4. 显示图像大小的框应在代码中调整,如果需要,图像应调整大小或拉伸以适合框。
  5. PS:服务器是PHP服务器

1 个答案:

答案 0 :(得分:3)

你需要的是这个: 1.通过Java,PHP或其他服务器端语言读取图库文件夹的文件。 2.列出他们的名字(如果你喜欢其他信息)。 3.通过javascript或jQuery显示它们......

您可以在PHP中使用此代码来读取文件夹文件:

$dir = getcwd()."/ImageGalleryFolder/";

if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if (($file != '.') && ($file != '..' ) && !is_dir($dir.$file)) {

                                // YOU HAVE FILENAME HERE ($file), USE IT AS YOU LIKE!
                                // note: the complete path of your file is $dir.$file
                        }
                }
        }
}

有许多免费的javascript和jQuery Image Sliders&网络中的旋转木马...其中一些甚至可以读取图像文件夹(但我不记得他们的名字)......

看看这些地方(你可以通过谷歌搜索找到更多)......

http://www.blogohblog.com/20-killer-image-sliders-carousels/

http://www.vivalogo.com/vl-resources/javascript-slideshows-sliders-carousels.htm