looping through the list of thumbnails and linking them to larger images using Flickr API and Jquery -
i trying display thumbnails flickr , link them larger images.
thumbnail portion working, can't "wrap" thumbnails link larger image.
got piece of code elsewhere links thumbnails own source , works.
//var url set above https://api.flickr.com/services/rest/? bla bla // loop through photos var src; $.getjson(url + "&format=json&jsoncallback=?", function(json_received){ $.each(json_received.photoset.photo, function(i,item){ thumbnail = "https://farm"+ item.farm +".static.flickr.com/"+ item.server +"/"+ item.id +"_"+ item.secret +"_q.jpg"; large = "https://farm"+ item.farm +".static.flickr.com/"+ item.server +"/"+ item.id +"_"+ item.secret +"_b.jpg"; $("<img/>").attr("src", thumbnail).appendto("#images"); //add links - thumbnails linked $("img").each(function() { $(this).wrap("<a href='" + this.src + "'/>"); }); }); });
i tried $(this).wrap("<a href='" + large + "'/>");
images linked last large image in list of images.
have attach "large" value each image somehow.
second time use jquery, bear me :)
before appending #images
wrap image anchor tag , append it.
you can use .wrapinner() , instead
var $img = $("<img/>").attr("src", thumbnail); $("<a href='" + large + "'/>").wrapinner($img).appendto("#images");
Comments
Post a Comment