LD TechnoLogics PHP Image Gallery Slideshow Fused With Picasa Web Google API - Updated 2007/06/28
(June 28, 2007)
When I reviewed my photosets here, I got surprised to find them offline. The culprit was traced to Google's ever-changing DOM/XML output. Yep, until now, they're still changing it. This means I had to update my image gallery engine to be able keep up. This also provided me an opportunity to significantly speed up the engine. So I sat down and did some modifications. I came up with 2 updated versions:
- One with DOM/XML support.
- Another one without DOM/XML support. I did this because my webhost has yet to enable this feature in its PHP installation (as of this writing), but they said they'll be turning this on soon.
Both versions, however, now enjoy full session caching support. This significantly speeds up a user's browsing experience. Well, actually, the experience gets faster and faster as his/her browsing session wears on. Admittedly, from my personal experience, however, it appears that Google (or PicasaWeb) passively delays GData and image file requests - or maybe this is just an effect of its load-balancing technology. Understandably, they have to throttle GData and image requests so they don't get flooded by external threads that do not make use of their ads. Whatever the case, these new versions now only request for GData once initially, per album, per user session, per browser. After getting the GData, the image gallery engine caches this in session variables. Successive page requests effectively bypass asking for GData needlessly again - unlike in the previous version, so only the image files get requested - and probably cached by your browser depending on its intelligence. Of course, it is important to first call a session_start() to enable PHP support for sessions, especially in stand-alone applications of these image gallery versions.
I kept the old version for legacy safekeeping, just in case. The helper function found in ldigs_function.php, however, has been updated to accommodate DOM/XML requests.
Zoom in this document to find the updated instructions set below.
Sample implementation of an updated version: http://www.loloyd.com/blog/nso_bike_rack_gets_devirginized
(April 16, 2007)
Finally, I am able to finish, with satisfying results, my PHP Image Gallery with Slideshow fused with the Picasa Web Google API. Now, I can make my web-based photo albums all centrally available from my website. And with Google's mindset of ever-expanding space allocations, I can rest my butt and wallet. As of this writing, my Picasa Web account has a 1 Gigabyte limit... and counting. Thank God, for Picasa Web and Google API.
Just follow my simple instructions, and you can use this API code too for your own purposes - on your own websites, for free!
To maintain the initial featureset of my original image gallery, I had to make a few key adjustments. One of these is on putting my slideshow formation function onto a separate file. This was necessary in order to commit to the somewhat unique featureset of my LD TechnoLogics Image Gallery With Slideshow Fused With Picasa Web Google API:
- Ability to present multiple photoset albums simultaneously in a single page, albeit with some known quirkiness. The quirkiness can be described as synchronous image zooms, i.e., zoom in on one image from one album and the other albums zoom in too on that specific image number if it exists.
You can try and see this in action by zooming in an image from the page http://www.loloyd.com/taxonomy/term/photosets. Zoom in on a single image from any album on that page, and you will note that the other albums will also show an image with the corresponding image number.
- Slideshow functionality - hey, not all image galleries can boast of this feature. :-D But since I'm releasing this as an open-source freedom-use API, now all other image galleries potentially can! :-D
- Relative ease in hackability/configurability/modifiability.
- Custom primitive XML parser for the Google API feeds!
Heck, this may even perform faster than that built-in xml_parse PHP function (it does so from my tests) and I can speculate why. My custom parser is made up of simple and light-weight functions that target specific strings.
- Portability. Works standalone. Works plugged in CMSs or CMS frameworks - especially Drupal (grin).
- Usual yada-yada, i.e., small (around 10 kilobytes), fast and efficient.
(Timeless information)
Sample implementation: http://www.loloyd.com/photosets/2007_iriga
Requirements and Instructions for Use
Important Note: This code has been released under the usual terms of GNU/GPL. Although not necessarily expected, a back-reference or trackback to my website http://loloyd.com/ is requested and very much appreciated.
- You must have a valid and working Picasa Web account. You must also have a few publicly viewable albums in your Picasa Web account.
Of course, it goes almost without saying that your Picasa Web albums should have at least one image each.
- Pick up the coded name of your Picasa Web album. Normally, it's how you named it minus whitespaces. So, if you named your album "My Silly Romantic Getaway", it could be name coded as "MySillyRomanticGetaway". Get this by browsing your Picasa Web album and examining its URL. It should be in the form http://picasaweb.google.com/username/SpacedOutAlbumName
- Download ldigs_functions.php.txt.
- Download
ld_picasa_dom.php.txt if you want to use the DOM/XML version. Be sure your PHP setup supports this.
ld_picasa_domless.php.txt if you want to use the version without DOM/XML support. This is applicable for those with older PHP versions.
- Edit the contents of the file ld_picasa_dom.php.txt (or ld_picasa_domless.php.txt) to reflect your own Picasa Web account settings.
For standalone implementations (meaning those that do not have wrapper applications like CMS's such as Drupal), you have to insert the line
session_start();
at the very top of this file you're editing.Be guided by the area marked with "//--- Settings Section Begin ---//" and "//--- Settings Section End ---//" - which tells you where and how you can configure this API for your own use.
- Rename ld_picasa_dom.php.txt to ld_picasa_dom.php (or ld_picasa_domless.php.txt to ld_picasa_domless.php) and ldigs_functions.php.txt to ldigs_functions.php.
For hot-plugging purposes (those who use CMS wrappers), copy the relevant contents of ld_picasa_dom.php (or ld_picasa_domless.php) onto the framework of your choice; just be sure that your relative reference to ldigs_functions.php is correct when you run it.
- Upload ldigs_functions.php to your server. For both standalone and hot-plug implementations, make sure that you have referenced ldigs_functions.php correctly.
For standalone versions, upload ld_picasa_dom.php (or ld_picasa_domless.php). If you plan to display multiple photo albums across various ld_picasa_*.php files, you may want to rename ld_picasa_*.php to something with a unique album reference first like picasaweb_album_name.php.
- Test your setup by browsing your uploaded ld_picasa_*.php, picasaweb_album_name.php or hot-plugged resource. If everything works fine, good! Pat your back. Congratulations!
- If you have questions and comments, feel free to leave some by clicking on the link "Add New Comment" below.
Good luck.
For your convenience, I have also provided the contents of all the files mentioned for quick copy and paste procedures:
ld_picasa_dom.php
ld_picasa_domless.php
ldigs_functions.php
picasaweb.php (deprecated)
Known Issues
- According to my tests, this may not satisfactorily work when you have more than 100 images in a single album. You might also experience difficulty when implementing this for albums containing even just around 100 images. You would get an empty response when you browse your album. Google's feeds may come too slow or my webhost may have a slow pulling connection. In any case, there are ways that I am toying with in order to address this.
One is to to play with PHP settings manually, like pre-pending ld_picasa_*.php with something like:
set_time_limit(0);
ini_set("max_execution_time", "300");
ini_set("max_input_time", "300");
ini_set("default_socket_timeout", "300");
ini_set("socket_timeout", "300"); //I made this particular line up, I'm fishing hereTake note that this may or may not work for you.
The other way around this problem is to limit the number of your Picasa Web album images to just 50 or so. I know that sucks but that's just about it for now.
- (Deprecated) My custom XML parser fails when Google decides to change their XML formats (applies mostly or only to the DOMless version). (Fixed!) I'll have to fix this soon with a DOM-complaint set of functions (sigh, no more unreliable custom XML parsers from hereon).
Future Directions
- (Done!) Caching support for Drupal-based implementations to speed up the browsing experience.
- (Done too!) Support for a supposedly more robust machine-to-machine query engine. Or maybe provide options.
- loloyd's blog
- Login to post comments
- 5810 reads




