How can I make animated thumbnails for my gallery of videos?

Concern about web page photo gallery and impact on server load

  • I'm setting up a new set of image gallery web pages for a site recently redesigned with Twitter Bootstrap framework. Based on past experience I'm concerned about possible server load issues, but since this is new tech now maybe I'm just paranoid? Full explanation inside... Web site is for a yearly convention/social event that people come to from around the world. Lasts over a weekend, and each day we post a gallery of pictures from the previous day, anywhere from 200 to 800 pictures per day. The previous version of the site, created around 5 or 6 years ago, used http://galleryproject.org/. The first year we used it, we allowed the "slideshow" option, and on the last day of the event, we had so many server hits using the slideshow that our webhost shut us down for a couple hours. Our most-viewed day of the year, and our site was offline. I can't have that happen again, so I never again allowed the slideshow view in the Gallery2 software. In January I redesigned the site using Bootstrap to allow for mobile responsiveness (our #1 browser is iPhone) and it's been extremely well received. Only thing I haven't finished yet is the photo galleries. I think I've settled on using http://blueimp.github.io/Bootstrap-Image-Gallery/ package. It doesn't auto-create thumbnails and it doesn't auto-paginate, which I would love, but I think I can get around that. My concern is about how many images to include per page, and whether the slideshow view could possibly cause the same server load issues we had before. It would be awesome if I could just have one page of images per day, but when there are 600+ pictures, that's a helluva lot of thumbnails. So far I've only tested with a page of just under 200 images, and I must say I was pleasantly surprised at how quickly it loaded on my iPhone over LTE (not WiFi). (Our webhost now uses https://developers.google.com/speed/pagespeed/?csw=1 tools.) The full size images range in file size from 60KB to 120KB, with the average probably somewhere around 80-90KB. Other possible concern - In order to avoid having to manually create the links to all the images, I've come up with a way in PHP to scan a folder and create them automatically. But that means the server is going to have to work to scan the folders every time someone loads the page. I thought maybe I could run that once on the server then copy/paste from the resulting page source, to create a static file, but the page speed optimizations add a piece of code to each image link so I'd have to remove those manually, which defeats the "not manually editing hundreds of links" purpose. In short, when a few hundred thousand people in one day try to view hundreds of pictures through this Bootstrap slideshow, is this going to make our webhost freak out again, or will this be OK, given the new technology today and that this collection of CSS and scripts is much smaller than the previous one? I'm not fully tech-savvy, this is a side project not my actual job so I'm not as fully up to speed with these kinds of issues as I could be, so that's why I'm reaching out to you folks. Thanks for any advice, and if I haven't explained things well let me know and I'll try to clarify.

  • Answer:

    Also, I know you mentioned the slideshow doesn't paginate or create thumbs, but both those things are huge. If most people look at a lot of thumbs and only a few big images, you don't want to load all the big images they don't want. You probably know this, but even if you scale them down with css you're still doing the work of loading the whole file. And if most people don't look at all 600, the ideal solution is to "lazy load" say 20 at a time, and get more as they scroll down or whatever and need more.

dnash at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

This is quick and dirty, but two things I'd consider: Get a batch renaming program and rename the images something predictable like [eventname]_[date]_[number] Now you don't have to do anything crazy in php; as long as you know the total number of images it's easy to generate links programmatically. It sounds like your server might have gotten killed by huge amounts of requests for images. I'd consider hosting them somewhere else, like Amazon S3, and linking to them. Your webserver should be serving webpages, not static files. Most big sites have another domain (www.facebookmedia.com or something), but a lot of people use S3 too.

drjimmy11

The amount of JS and CSS in a page shouldn't matter, although less files is better than more. It would literally be hard to slow down a website with too much css if you tried. Text is incredibly small compared to media.

drjimmy11

It depends. There are two things that could cause your host to freak out, and you don't specify which one:CPU Load - Gallery2 shoves images through a PHP script so that its permissions model works correctly, so it can potentially cause more server load than if it just let your webserver serve the images directly (static files almost always take fewer resources to serve than scripts). If all your new solution does is scan the directory for new images and adds them to a list (which you're then caching somewhere so it doesn't have to regenerate every single time, right?), then that's probably going to reduce the server load a fair bit. If you still have your Gallery2 install around you could upload a small set of images to it and your new system and then compare the CPU load with both, if you want to really reassure yourself. If you don't know how to measure CPU load, you might ask your web host for assistance.Bandwidth - It really doesn't matter whether it's Gallery2 or something else serving those images when it comes to bandwidth. They're going to cost the same amount either way. However, it should be easy enough to estimate how much bandwidth will be used by figuring how big an average picture will be (in KB) and then multiply that by the number of pictures in the slideshow and by the number of users you expect to see in the worst case.All that said, I'd either recommend against providing a slideshow (instead provide a page with thumbnails that link to larger images, and http://www.appelsiini.net/projects/lazyload), or if you do, make sure that it doesn't auto-advance without user intervention (so that a user can't just visit it and eat your bandwidth while they ignore it). Unless it's something users are clamoring for, it seems like an unnecessary and potentially costly feature to have. If you must have an auto-advancing slideshow, I'd recommend making a YouTube video of the pictures and embed that instead. That way you don't pay any of the costs for hosting it aside from the page that embeds the video.

Aleyn

Aleyn - thank you, you just brought up something I didn't discuss in the post that I think might be the central issue. I'd sort of forgotten that indeed the issue that crashed the server was the auto-advancing slideshow. I turned that off, but a viewer could still pull up a full-size view (not in a "lightbox," but within the Gallery page) and just keep clicking "next." This solution I'm looking at now would be the same thing, as far as I can see - it's not auto-advancing, you just keep clicking "next." The catch though is the Gallery solution made pretty large thumbnails, and auto-paginated so it would only show 9 at a time. With the large thumbnails it's more likely a user will browse and only view full-size for a smaller number of pictures. This new Bootstrap solution, I have control of the thumbnail size but the larger they are the fewer I can safely put on a page and the more individual pages I will have to manually create. With smaller thumbnails, it's more likely a viewer - especially on a mobile device - will click to full-size images and swipe through them.

dnash

Oh, regarding this:Other possible concern - In order to avoid having to manually create the links to all the images, I've come up with a way in PHP to scan a folder and create them automatically. But that means the server is going to have to work to scan the folders every time someone loads the page. I thought maybe I could run that once on the server then copy/paste from the resulting page source, to create a static file, but the page speed optimizations add a piece of code to each image link so I'd have to remove those manually, which defeats the "not manually editing hundreds of links" purpose. Have you considered running your script on a machine that you control so that it doesn't go through the Google Page Speed Optimization stuff? Then you'd just upload the static result to your webserver, no editing needed.

Aleyn

Would it be possible to off-load the gallery functionality to a dedicated web service like smugmug? You could customize layout and domain to match your organization, but let their servers do the heavy lifting.

any portmanteau in a storm

Get a batch renaming program and rename the images something predictable like [eventname]_[date]_[number] Now you don't have to do anything crazy in php; as long as you know the total number of images it's easy to generate links programmatically. drjimmy11 - Thanks. I use Adobe Bridge & Photoshop. Bridge renames. I'm still tweaking a Photoshop action to create the thumbnails. The solution I'm looking at needs this:<a href="imagefilename.jpg"><img src="thumbnailname.jpg"></a>Like I said, I'm not fluent in PHP and JavaScript, but I found a PHP way to generate a list of filenames that are in a certain directory. So I'm going to name the thumbnail files exactly the same with a small prefex ("imagefilename.jpg" and "thumb_imagefilename.jpg") so that the PHP code can use the file name it finds in both places.

dnash

Have you considered running your script on a machine that you control so that it doesn't go through the Google Page Speed Optimization stuff? Then you'd just upload the static result to your webserver, no editing needed. Y'know, it hadn't occurred to me but I just might be able to do this. I own another domain myself, on another host - I'm not sure if I can run PHP on it but maybe I can. It might be too much work to do during the actual event weekend, because it would mean uploading hundreds of files to TWO servers not one, via a hotel Internet connection (and those are never the best), but if I do it now for previous years (yes, we keep all previous years' galleries up) then the only new "dynamic" pages will be the brand new ones, and I can turn them static later.

dnash

Would it be possible to off-load the gallery functionality to a dedicated web service like smugmug? Yeah, I went into full-on programming mode there, but if it was me I'd put them on flickr or 500px, pay for a pro account as needed, and let people have at it, honestly.

drjimmy11

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.