Advertisement
Guest User

script

a guest
May 16th, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function() {
  2.  
  3.     function flickr_feed(flickrID, flickr_count, photo_size) {
  4.  
  5.         var flickrAPI = '12a49355728ae8a0baa555cb07bcb767';
  6.         var getSize;
  7.  
  8.         if (photo_size == 'square-1') getSize = 'url_sq';
  9.         if (photo_size == 'square-2') getSize = 'url_q';
  10.         if (photo_size == 'thumbnail') getSize = 'url_t';
  11.         if (photo_size == 'small-1') getSize = 'url_s';
  12.         if (photo_size == 'small-2') getSize = 'url_n';
  13.         if (photo_size == 'medium-1') getSize = 'url_m';
  14.         if (photo_size == 'medium-2') getSize = 'url_z';
  15.         if (photo_size == 'medium-3') getSize = 'url_c';
  16.         if (photo_size == 'large') getSize = 'url_l';
  17.         if (photo_size == 'original') getSize = 'url_o';
  18.  
  19.         $.ajax({
  20.             url: 'http://api.flickr.com/services/rest/?&method=flickr.people.getPublicPhotos&api_key=' + flickrAPI + '&user_id=' + flickrID + '&per_page=' + flickr_count + '&page=0&extras=' + getSize + '&format=json&jsoncallback=?',
  21.             type: 'GET',
  22.             dataType: 'jsonp',
  23.             timeout: 5000,
  24.             cache: false,
  25.             success: function(data) {
  26.                 $.each(data.photos.photo, function() {
  27.                     var photoURI = 'http://www.flickr.com/photos/' + flickrID + '/' + this.id;                 
  28.                     var photoSrc = this.getSize;
  29.                     console.log(photoSrc);
  30.  
  31.                     var photoTitle = this.title;
  32.                     var flickr_html = '<div class="flickr-photo"><a href="' + photoURI + '" title="' + photoTitle + '" target="_blank"><img src="' + photoSrc + '"></a></div>';
  33.  
  34.                     $('#flickr-photos').append(flickr_html);
  35.                 });
  36.             },
  37.  
  38.             error: function () {
  39.                 $('#flickr-photos').append('<p>Flickr&rsquo;s API service is experiencing some technical difficulties. Please try again later.</p>');
  40.             }
  41.         })
  42.     }
  43.  
  44.     flickr_feed('28634332@N05', 10, 'square-1');
  45.  
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement