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”

lol, yeah Joe, I meant display:none;. I did and I forgot to post about, I am heading out the door right now, and will try to have a response for you when I get back.

Thanks Benjamin, that hid the broken img icon, but you meant display:none instead of display:block, no?

Were you able to have a look about passing the json img title over? I was able to append an h2 in there, and just need the method to pass it in. Thanks again!

@joe: sorry for the later reply, at about line 90 of the jqGalViewII.js file you can make a change to hide the image like:

JavaScript:
  1. //change
  2. el.image = $('<img/>').appendTo(el.mainImgContainer);
  3. //to
  4. el.image = $('<img style="display:block;"/>').appendTo(el.mainImgContainer);

What that should do, is "hide" the img the fadein code executed which happens at about line 194.

Let me know if that works.

Hi Benjamin,
I've got an h2 stubbed in here: http://junktrunk.com . click on the image of Tom to load the gallery.

In firefox it appears to be showing a broken img icon right before the ajax-loader gif shows before the first image loads.

thanks again for the help! I'm really diggin this thing.

Joe

Jo,
Looks like you will need to make two changes to the code. Let me experiment and I will try to get back to you tonight. Do you have a link to what you have so far so I can have an idea of what structure you are working with?

What a most excellent plugin! Thank you!

How might I append the code to be able to display the title of the large image in an h2 or something or the like? Seems as the though the thumbnails have the Flickr title, however it is not passed into the large image. Thank you again.

Jo

Chris,
The script should grab all thumbnails that are passed back from what ever account you are using unless you set the "count" param to 20. Do you have a url I can have a look at?

is there a reason or way around the fact that it will only display up to 20 thumbnails?

M.
I am in the process of updating this plugin to make it output something better and that will work better with the update of jqGalView, my other plugin and most of the other photo gallery type plugins.

That won't be ready for another few days, but if you want a quick fix till then, the code below should work.

@ about line 226 that starts "for(i in photos){"

Change:

JavaScript:
  1. $item.append('<img src="'+photos[i][item.opts.buildFrom]['url']+'" alt="'+photos[i]['title']+'" title="'+photos[i]['title']+'"/>');

to:

JavaScript:
  1. $item.append('<a href="'+photos[i]['full']['url']+'" rel="nofollow"><img src="'+photos[i][item.opts.buildFrom]['url']+'" alt="'+photos[i]['title']+'" title="'+photos[i]['title']+'"/></a>');

Like I said, I am hoping to get this plugin updated in the next couple of day and will have better instructions/documentation, as you can see, my docs suck and it is not one of my strong suits.

Hi,

i really love your plugin!

But how must the markup look like when using the Parser with the updated PhotoGallery 2.0??

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.717 seconds. Powered by WordPress visitor stats