加载图片之前运行 jQuery
你好 我在使用 php 和 jQuery 创建动态画廊时遇到问题。 简而言之,我有一百张想要以漂亮的形式显示的照片(用于摄影师的网站)。图片已经过优化,所以整个图库的重量约为10mb。
我正在使用 galleryView 插件。 php 用于从图像文件夹中获取所有文件名并创建 s.php 的无序列表。 GalleryView 然后获取列表并创建一个简洁的图库。
我遇到的问题是你必须等待图库显示,直到所有图片下载完毕。 10mbs,需要很长时间。
是否有一个简单的选项可以在仅下载几个文件后运行图库?
或者有人知道更好的方法吗?一些不错的 jQuery 画廊插件可以处理很多图像?我一直在寻找一个非常不成功的人。
提前致谢
Hi
I'm having a problem with creating a dynamic gallery with php and jQuery.
In simple words, I have got a hundred pictures I want displayed in a nice form (for a photographer's website). Pictures have been optimized, so the whole gallery weights about 10mb.
I am using the galleryView plugin. php is used to take all filenames from the images' folder and create an unordered list of s.
GalleryView then gets the list and creates a neat gallery.
The problem I've got is that you have to wait for the gallery to show until all the pictures are downloaded. with 10mbs, it takes ages.
Is there a simple option of running the gallery after only a few files are downloaded?
Or does anyone maybe know a better way of doing it? some nice jQuery gallery plugin that can handle many images? I've been quite unsuccessful searching for one.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
galleryView 中似乎没有任何对预加载图像的本机支持。从规格来看:
所以你必须自己推出。
看一下 jQuery
.load()
功能。加载后显示第一张图像,然后在后台加载其他图像。
假设第一张图片位于
id
=first
中,根据需要修改上面的内容。假设您想显示第一个大图像和前 5 个缩略图等。
我将这样开始。我认为如果您不仅预加载第一张图像,而且预加载尽可能多的图像来填充第一行拇指,它可能看起来会更平滑。
仅显示一张图像的临时
div
,直到加载所有图像:HTML:
JS:
There doesn't appear to be any native support of preloading images in galleryView. From the specs:
So you have to roll your own.
Take a look at the jQuery
.load()
function.Show the first image once it's loaded, then load the others in the background.
Let's say the first image is in
id
=first
Modify the above as needed. Let's say if you want to show the first big image and first 5 thumbnails, etc.
Here's how I'd start. I think it'd probably look smoother if you preloaded not just the 1st image, but as many images as it takes to fill up the first row of thumbs.
Show a temporary
div
with just one image until all the images load:HTML:
JS:
JQuery Cycle 插件是一个超级可定制的选项,请查看@ http://jquery.malsup.com/cycle/
他们甚至有一个预加载示例 @ http://jquery.malsup.com/cycle/ add3.html
JQuery Cycle plugin is a ultra-customizable option, check it out @ http://jquery.malsup.com/cycle/
They even have a preloading example @ http://jquery.malsup.com/cycle/add3.html
@Peterajtai
不,你是对的,我没有看到。对我来说最好的方法是从几张图片开始:(下面是来自 galleryview 默认实现示例):
然后像这样运行 ajax:
您可以使用相同的功能来构建列表项和appendTo('ul.filmstrip') ;
就我个人而言,我会在 php 端使用 for 循环构建图像块,并将它们准备好插入
,或者您可以构建 xml feed 或 json 对象并将其通过。您的个人选择。
@Peterajtai
no, you're right, I don't see one. Best way for me is then is start with a few images in place: (below is from galleryview default implementation example):
then run ajax like so:
You could use the same functionality to build list items and appendTo('ul.filmstrip');
Personally I would build the image blocks using a for loop on the php side and bring them in ready to insert
Or you could build an xml feed, or json object and bring that through. Your personal choice.