如何收集所有从文件夹中的图片 [英] How to collect all the images from a folder

查看:225
本文介绍了如何收集所有从文件夹中的图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此小提琴

当你点击下一步,然后新的图像loaded.But新的图像是从互联网下载。

when you click on next then new images are loaded.But the new images are loaded from internet.

在我的应用程序的所有图像都位于 IMG /图片文件夹和图像名称的 1.JPG,hi.png

In my app all the images are located in img/image folder and the image names are 1.jpg,hi.png etc

所以,我怎么能显示图像时,我点击下一步

So how can I show the images when I click on next

我想我会修改 VAR SRCS = ['http://lorempixel.com/150/100/city','http://lorempixel.com/150/100/sports'] ; VAR SRCS = ['IMG /图像/ 1.JPG,IMG /图像/ hi.png'];

但是,如果我这样做的方式,那么问题将是我不得不改变 VAR SRCS 如果我一个新的形象添加到文件夹

But if I do this way then the problem will be I have to change var srcs if I add a new image to the folder

例如如果以后以后我补充 3.JPG ,然后我必须手动 VAR SRCS = ['IMG /图像/ 1.JPG,IMG /图像/ hi.png','IMG /图像/ 3.JPG'];

For example If after a later time I add 3.jpg then I have to manually var srcs = [ 'img/image/1.jpg', 'img/image/hi.png','img/image/3.jpg' ];

推荐答案

下面的例子,可以帮助你,这不是最佳的,但工程的 http://jsfiddle.net/PrVRq/

Here an example that can help you, it's not optimal but works http://jsfiddle.net/PrVRq/ :

$('.images').on('loaded', function () {// load an image}

尝试加载下一个图像

try to load the next image

img.load(function () {    
    $('.images').append(img);
    $('.images').trigger('loaded');
});

如果加载图像触发Loaded事件载入另一个。

if the image is loaded trigger the loaded event to load another one.

这篇关于如何收集所有从文件夹中的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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