Thx. There was a bug in the extra line you gave me which I corrected.
Below is the full code you'll need for future reference:
http://codedumper.com/flickr-api-using-jquery-json




On Dec 12 2008, 4:58 pm, ricardobeat <ricardob...@gmail.com> wrote:
> According to the API the URL is in item.link, so you just need to wrap
> the image in an anchor:
>
> function(data){
>           $.each(data.items, function(i,item){
>             $("<img/>").attr("src", item.media.m)
>                 .appendTo("#images")
>                 .wrap('<a href="'+item.link+'"></a>");
>             if ( i == 4 ) return false;
>           });
>         });
>
> On Dec 12, 9:45 am,desbest<afanintheho...@gmail.com> wrote:
>
> > ================
> > HERES THE TASK
> > ================
> > To get the 5 newest photos from Flickr tagged with the word "light".
>
> > ================
> > HERES THE CODE
> > ================
> > <html>
> > <head>
> >   <script src="../jquery.js"></script>
>
> >   <script>
> >   $(document).ready(function(){
> >     $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?
> > tags=light&tagmode=any&format=json&jsoncallback=?",
> >         function(data){
> >           $.each(data.items, function(i,item){
> >             $("<img/>").attr("src", item.media.m).appendTo("#images");
> >             if ( i == 4 ) return false;
> >           });
> >         });
> >   });
> >   </script>
> >   <style>img{ height: 100px; float: left; }</style>
> > </head>
> > <body>
> >   <div id="images"></div>
> > </body>
> > </html>
>
> > ==================
> > HERES THE OUTPUT
> > ==================http://sampleswap.uk.to/json/test.html
>
> > ==================
> > The src of the image is the item.media.m
> > According to the flickr api (http://www.wait-till-i.com/2007/10/22/
> > hacking-flickr-the-json-way/)
> > the href of the image is item.link.m
>
> > How do I make the images be a hyperlink to to the actual Flickr page
> > of the image?

Reply via email to