Created
August 15, 2012 16:52
-
-
Save stevedev/3361556 to your computer and use it in GitHub Desktop.
Simple jQuery Facebook Album Script
This file contains 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
#photo-container { | |
padding: 15px; | |
} | |
#photo-container a { | |
overflow: hidden; | |
display: block; | |
float: left; | |
border: 1px solid #cdcac6; | |
padding: 0; | |
margin: 0 7px 10px 8px; | |
width: 126px; | |
height: 98px; | |
} | |
#photo-container a span { | |
display: block; | |
overflow: hidden; | |
width: 118px; | |
height: 90px; | |
border: 4px solid #FFF; | |
} | |
#photo-container img { | |
display: block; | |
} |
This file contains 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
<div id="photo-container"></div> |
This file contains 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
$(function() { | |
var album_id = '376995711728'; | |
$.ajax({ | |
url: 'http://graph.facebook.com/' + album_id + '/photos?fields=images', | |
dataType: 'jsonp', | |
success: function(data) { | |
var fb_images = data.data; | |
if (fb_images.length > 0) { | |
$.each(fb_images, function(i, o) { | |
var img_obj = o.images[o.images.length - 3]; | |
var img = $('<img>', { | |
src: img_obj.source | |
}); | |
var a = $('<a>', { | |
href: o.images[0].source | |
}); | |
var span = $('<span>').append(img); | |
$(a).append(span); | |
$('#photo-container').append(a); | |
}); | |
$('.fancybox a').fancybox(); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment