0

我想使用我自己的幻灯片而不是为我的 joomla 模板使用一些插件。因此,我需要预加载图像,因为在插件中图像是从文件夹中获取的。所以我的问题是如何从特定文件夹创建一个数组,例如。my-template/bg拍摄所有图像,最后上传的图像应该在数组的最后。

4

2 回答 2

1

这是我未经测试就一起破解的建议:-)

在您的模板中:

<script>var imgObj = <?php echo $this->getDirectory('images');  ?></script>

在 jQuery 的文档就绪块中

// load images into DOM and wait for load event
if (typeof window.imgObj === 'object') {

      $(window.imgObj).each(function (index) {
         var url = window.imgObj[index],
             image = $('<img src="' + url + '" />');

      //for old non webkit-opera you need to do a hack like
      image.appendTo('body').remove();

      image.on('load', function () {
         //do stuff with the image once loaded
      }
   }
}
于 2013-07-14T14:34:17.733 回答
0

短裙:

jQuery 使用 Ajax 调用 PHP 脚本,该脚本从该文件夹中获取文件名。

或者

PHP 使用具有文件名数组的嵌入 javascript 一次生成页面 (HTML)。

在这两种情况下,PHP 都可以测试文件日期和时间以对数组中的文件名进行排序。

于 2013-07-14T14:11:20.897 回答