/* * copyright (c) 2009 joel sutherland * licenced under the mit license * http://www.newmediacampaigns.com/page/jquery-flickr-plugin * * available tags for templates: * title, link, date_taken, description, published, author, author_id, tags, image* */ (function($){$.fn.jflickrfeed=function(settings,callback){settings=$.extend(true,{flickrbase:'http://api.flickr.com/services/feeds/',feedapi:'photos_public.gne',limit:20,qstrings:{lang:'en-us',format:'json',jsoncallback:'?'},cleandescription:true,usetemplate:true,itemtemplate:'',itemcallback:function(){}},settings);var url=settings.flickrbase+settings.feedapi+'?';var first=true;for(var key in settings.qstrings){if(!first) url+='&';url+=key+'='+settings.qstrings[key];first=false;} return $(this).each(function(){var $container=$(this);var container=this;$.getjson(url,function(data){$.each(data.items,function(i,item){if(i(.*?)<\/p>/g;var input=item.description;if(regex.test(input)){item.description=input.match(regex)[2] if(item.description!=undefined) item.description=item.description.replace('

','').replace('

','');}} item['image_s']=item.media.m.replace('_m','_s');item['image_t']=item.media.m.replace('_m','_t');item['image_m']=item.media.m.replace('_m','_m');item['image']=item.media.m.replace('_m','');item['image_b']=item.media.m.replace('_m','_b');delete item.media;if(settings.usetemplate){var template=settings.itemtemplate;for(var key in item){var rgx=new regexp('{{'+key+'}}','g');template=template.replace(rgx,item[key]);} $container.append(template)} settings.itemcallback.call(container,item);}});if($.isfunction(callback)){callback.call(container,data);}});});}})(jquery);