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”

Brain, I'm sorry, I missed your comment also, You should be able to do something like:

JavaScript:
  1. it.opts.appendTo = (cls.match(/appendTo:(\w+)/)||[])[1] || it.opts.appendTo;

HTML:
  1. class="wa:picasa appendTo:#myelement"

That should work; but it is untested.

netcomp,
Sorry, I've been wrapped up in some other items. It looks like Flickr limits rss feeds to 20, there is an alternatives, but will require you getting an api key (http://www.flickr.com/services/api/keys/) and then what we will need to do is adjust a few items in the code to let us play with a different url that we can create that will return all the images. So get that api and contact me off list and I can walk you thru the changes; they should be very minor.

any luck with the count limitation? I can't figure it out....

TIA

Hi Ben, no I'm not setting any count params. heres a link.
http://www.lucky13tattoos.ca/flickr_test.asp

Is there a way I can make the larger images "larger"?

TIA

ps great plugin!

Hey Ben, Did you get a chance to look into my request? #23 Thanks again. Brian

TIA, that answer is still that same, he never got back to me so I am not sure of what his settings were. Can you show me the url you are pulling from and are you setting count?

Ben, was there an answer for post #3? I am running into a 20 thumbnail limit although there is 113 available.

TIA

Ben, I want to pass a variable like you are doing for the wa:picasa. So, on your album link you have class="jqAlbumParser wa:picasa". I want to pass the appendTo variable too. So, I have tried class="jqAlbumParser wa:picasa appendTo:#putHereID" but it does not seem to recognize the appendTo. If I open the jqAlbumParser.js file and edit the appendTo attribute in the default settings it works. But I want multiple galleries on a page, that I can open and close, the best way to do this would be to pass the ID of the div in the appendTo attribute. Then I can close the div by a "close" link, that will hide the open gallery. So, how do I pass the variable :^) Thanks for your effort.

Brian: Not sure what you mean by "pass a variable to the appendTo"? Can you elaborate?

To tell you the truth, I never even thought about closing a gallery after it is opened. It never crossed my mind. Let me take a look at a few things to see what can be done. Maybe appending a link after the initial link with the text "close gallery" and giving that a click event that will just remove the gallery. $('SELECTOR').remove(); I will try to come up with something this weekend but not entirely sure I will have time.

Ben, how do I hide or close the gallery after it has been opened?

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