-
-
Save palimadra/8727733 to your computer and use it in GitHub Desktop.
Embed a Facebook gallery into your website
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8'> | |
<title>Embedded Facebook Page Photo Gallery with jQuery</title> | |
<style type='text/css'> #thumbs{float:left;width:200px;} #thumbs img{display:block;margin:0 0 10px;cursor:pointer;} #viewer{float:left;} </style> | |
</head> | |
<body> | |
<h1>Embedded Facebook Page Photo Gallery with jQuery</h1> | |
<h2></h2> | |
<nav id='thumbs'></nav> | |
<img id='viewer'> | |
<script src="//code.jquery.com/jquery-1.6.4.min.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
(function (gallery_id) { | |
var title = $('h2'), | |
viewer = $('#viewer'), | |
thumbs = $('#thumbs'); | |
// album info | |
$.getJSON('//graph.facebook.com/' + gallery_id + '?callback=?', function(json, status, xhr) { | |
title.html('<a href="' + json.link + '">' + json.name + '</a> from ' + json.from.name); | |
}); | |
// images | |
$.getJSON('//graph.facebook.com/' + gallery_id + '/photos?callback=?', function(json, status, xhr) { | |
var imgs = json.data; | |
viewer.attr('src', imgs[0].images[0].source) | |
for (var i = 0, l = imgs.length - 1; i < l; i++) { | |
$('<img src="' + imgs[i].images[3].source + '" data-fullsize="' + imgs[i].images[0].source + '">').appendTo(thumbs); | |
} | |
$('img', thumbs).bind('click', function(e) { | |
e.preventDefault(); | |
viewer.attr('src', $(this).attr('data-fullsize')); | |
}); | |
}); | |
})('426067170422'); // let's go -- put the gallery ID here | |
</script> | |
</body> | |
</html> |
We've made a working code tutorial for this one https://www.codeofaninja.com/2011/06/display-facebook-photos-to-your-website.html
But if you just want to do the trick quickly, you can use website plugins such as https://www.sociablekit.com/embed-facebook-page-photo-album-on-website/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note to others: this is out of date now since you'll likely need an access token. Anonymous queries like these appear to be deprecated or even disabled now.