Skip to content Skip to tags Skip to twitter news Skip to blog roll Skip to categories Skip to archives Skip to recent posts

September 13, 2007

jQuery: jqAlbumParser Plugin, parses out Flickr, Picasa clientside

by Benjamin Sterling in Javascript, Photogallery, Plugin, jQuery, jQuery Plugin on September 13, 2007 @ 11:46 pm

The jQuery jqAlbumParser Plugin takes a link linking to your Flickr or Picasa photo album and parses it into your current layout as is or hook in another plugin like the jqGalView Plugin, the jqGalScroll Plugin, the jqGalViewII Plugin or the jqShuffle Plugin to create your photo gallery on the fly and with very little coding on your part.

Why jqAlbumParser? Well, after building a few photo gallery plugins and plans for different variations of flash-like galleries (I am on a convert flash apps to jQuery ran apps kick), I found myself wanting to use other peoples photos, ie. friends and families, but did not want to download them. So I wanted to be able to bring in Picasa and Flickr photos, but sadly their JSON formats are different, I needed a way to pull them both in on the same page and be able to use them with the same functions and so I figured I'd bring their JSON and parse them to my own object and poof, jqAlbumParser! Anyway, I am rambling, check out below and if you have any question (since I know my comment and explanations suck) post a comment and I will get back to asap. Also, if you use this plugin, drop me your url and a brief description of your site and I will be sure to post it to my Plugin Repository page.

The Basic Demo




Picasa | Flickr

The Simple Code

The xhtml
HTML:
  1. <a href="http://picasaweb.google.com/data/feed/base/user/sterling.benjamin/albumid/5065213814603581825?kind=photo&amp;alt=rss&amp;hl=en_US" class="jqAlbumParser
  2. wa:picasa">Picasa</a>
  3. |
  4. <a href="http://api.flickr.com/services/feeds/photos_public.gne?ids=11983862@N00" class="jqAlbumParser
  5. wa:flickr">Flickr</a>

The head stuff
CSS:
  1. <style media="all">
  2.     @import url("/articles/jqGalViewII/common/css/jqGalViewII.css");
  3. </style>

JavaScript:
  1. <script type="text/javascript" src="/articles/common/js/jquery-1.2.1.pack.js"></script>
  2. <script type="text/javascript" src="/articles/jqAlbumParser/common/js/jqAlbumParser.js"></script>
  3. <script type="text/javascript" src="/articles/jqGalViewII/common/js/jqGalViewII.js"></script>
  4. <script type="text/javascript">
  5. $(document).ready(function(){
  6.     $(".jqAlbumParser").jqAlbumParser({
  7.         pluginExec : function(){
  8.             $(this).jqGalViewII();
  9.         }
  10.     });
  11. });
  12. </script>

The Small Print

So you see the set up is somewhat simple; in the example above I used the jqAlbumParser in conjuction with the jqGalViewII plugin so you can see how I envision a person would use this plugin. You will be able to use the jqAlbumParser with any of my plugin, and any photogallery plugin that works with the same structure that this plugin can put out.

To get the url for your Picasa album, go to your account and then the album you want; go to the bottom right corner and you will find a RSS feed link and either right click and click copy link location or click that link and copy the url from there.

To get the url for you Flickr album, go to the photo section of your account and go to the bottom left and copy the RSS link.

You will also notice that in the demo links that there is a "wa:picasa" and a "wa:flickr," if you are not going to add separate jqAlbumParser calls for different services, ie. Picasa and Flickr, you will need to add one of those to the correct link.

Now you are probably asking yourself, "How do I get this to execute when the page loads?" or "I tried 'load' as the "triggerEvent" but it does not work, how come?" The answer, do:

JavaScript:
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3.     $('.jqAlbumParser').jqAlbumParser({
  4.         pluginExec : function(){
  5.             $(this).jqGalViewII();
  6.         }
  7.     }).click();
  8. });
  9. </script>

or

JavaScript:
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3.     $(".jqAlbumParser").jqAlbumParser({
  4.         pluginExec : function(){
  5.             $(this).jqGalViewII();
  6.         }
  7.     }).trigger("click");
  8. });
  9. </script>

The download

http://benjaminsterling.com/ar.....mParser.js

Pages: « 4 3 [2] 1 » Show All

33 Responses to “jQuery: jqAlbumParser Plugin, parses out Flickr, Picasa clientside”

Got it figured out Ben. I edited the "appendTo" string in the jqAlbumParser with the ID of the . Worked like a charm. Now, my next step is to incorporate this into the jQuery Accordian. Is there a way to pass a variable to the appendTo?

Brain: You need to do $(this).jqGalViewII(); and not $(".putHere").jqGalViewII(); Try that and let me know if it works.

Sorry Div tags are like this

HTML:
  1. Gallery 1 <a href="http://picasaweb.google.com/data/feed/base/user/balmeter/albumid/5161830896280030449?kind=photo&amp;alt=rss&amp;authkey=9m0W3RYEy64&amp;hl=en_US" rel="nofollow">Picasa</a>
  2.        Content 1

Hi Ben,

I am trying to use your albumparser, which is great, on a web site. I am having the user click on a link for the photos, but then I want it to appear in a div container like so:

HTML:
  1. Gallery 1 <a href="http://picasaweb.google.com/data/feed/base/user/balmeter/albumid/5161830896280030449?kind=photo&amp;alt=rss&amp;authkey=9m0W3RYEy64&amp;hl=en_US" rel="nofollow">Picasa</a>

Content 1

I have tried changing the calling method to:

JavaScript:
  1. $(document).ready(function(){
  2.     $(".jqAlbumParser").jqAlbumParser({
  3.         pluginExec : function(){
  4.             $(".putHere").jqGalViewII(); // $(this).jqGalViewII();
  5.         }
  6.     }); // take out .click for others
  7. });

It only prints out the list of images, and not in the jGalViewII shell. How do I change this?

Thanks in Advance
Brian

i'm trying to get the plugin to work on:
http://www.webweb.co.il/t

but firefox produces an error and does not show the gallery, any idea why?
thanks in advance.

This works great! Thanks for putting this out there, you are strong to quite strong good sir ; )

thanks for this great plugin

Glad it worked out for you Joe, if you are dealing with JSON, jQuery and PHP, I would suggest that you take a look at my post about it called Using JSON in PHP4 and PHP5 with an included class or json_decode

Worked like a charm! I just started looking into json and the use of jquery for parsing last week. Your code is enlightening. Thanks so much! I'm gonna go try to horse in the description now. :D

Joe,
If you change at about like 93 in your file:

JavaScript:
  1. var $imgTitleHolder

to

JavaScript:
  1. el.imgTitleHolder

then change line 194:

JavaScript:
  1. el.loader.fadeOut('fast',function(){el.image.fadeIn();});

to

JavaScript:
  1. el.loader.fadeOut('fast',function(){
  2.      el.image.fadeIn();
  3.      el.imgTitleHolder.text(img.altTxt).fadeIn();
  4. });

That should do the trick, let me know if that works.

Pages: « 4 3 [2] 1 » Show All

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

RSS Feed Link

42 queries. 0.886 seconds. Powered by WordPress visitor stats