Created
December 19, 2016 12:11
-
-
Save hsleonis/2ee3e824c9cd70f180ca133dc623a438 to your computer and use it in GitHub Desktop.
Purses flickr public feed from API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.fn.flickr = | |
| function(arr){ | |
| var wrapper = this; | |
| $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id="+arr.id+"&lang=en-us&format=json&jsoncallback=?", displayImages); | |
| function displayImages(data) | |
| { | |
| // Choose where in the feed to start, 0 is latest | |
| var iStart = 0; | |
| // Reset our counter to 0 | |
| var iCount = 0; | |
| // Start putting together the HTML string | |
| var htmlString = "<ul>"; | |
| // Now start cycling through our array of Flickr photo details | |
| $.each(data.items, function(i,item){ | |
| if (iCount > iStart && iCount < (iStart + arr.num + 1)) { | |
| var sourceSquare = item.media.m; | |
| // Here's where we piece together the HTML | |
| htmlString += '<li><a href="' + item.link + '" target="_blank">'; | |
| htmlString += '<img src="' + sourceSquare + '" alt="' + item.title + '" title="' + item.title + '"/>'; | |
| htmlString += '</a></li>'; | |
| } | |
| // Increase our counter by 1 | |
| iCount++; | |
| }); | |
| // Pop our HTML in the #images DIV | |
| $(wrapper).html(htmlString + "</ul>"); | |
| } | |
| }; | |
| //you should set the images to the proper size with CSS | |
| //and there needs to a div with the id #images in the DOM | |
| // HTML: | |
| // <div class="images"></div> | |
| $(document).ready(function(){ | |
| $('.images').flickr({ | |
| id: '9890806@N04', | |
| num: 6 | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment