Overview
What Is Facebook Photo Fetcher?
Facebook Photo Fetcher is a Wordpress plugin that allows you to quickly and easily generate Wordpress photo galleries from any Facebook album you can access.
The idea was inspired by Fotobook, though its approach is fundamentally different: while Fotobook's emphasis is on automation, this plugin allows a great deal more customization. With it you can create galleries in any Post or Page you like, right alongside your regular content. You do this simply by putting a "magic HTML tag" in the post's content - much like Wordpress Shortcode. Upon saving, the tag will automatically be populated with the Facebook album content. Presentation is fully customizable via parameters to the "magic tag" - you can choose to show only a subset of an album's photos, change the number of photos per column, show photo captions, and more.
Also, Facebook Photo Fetcher does not limit you to just your own Facebook albums: you can create galleries from any album you can access, including groups and fanpages. This is very handy if you're not the main photo-poster in your social circle: just let your friend or family upload all those wedding pics, then import them directly to your blog!
Features:
- Uses Facebook's API to instantly create Wordpress photo galleries from Facebook albums.
- Galleries are fully customizable: you can import complete albums, select excerpts, random excerpts, album descriptions, photo captions, and more.
- Galleries can be organized however you like: in any post or page, alone or alongside your other content.
- Simple PHP template function allows programmers to manually embed albums in any template or widget.
- Galleries can be created from any album you can access: yours, friends', groups', or fanpages'.
- Built-in support for automatically attaching Post Thumbnails to any post or page that includes a gallery.
- Built-in lightbox: Photos appear in attractive pop-up overlays without the need for any other plugins.
- Admin panel handles all setup for you: Just click Connect, login, and you're ready to start making albums.
- Admin panel includes utility to search for all albums you can access (and use to create galleries).
- Admin panel includes utility to auto-traverse your galleries, updating those that've changed on Facebook.
- No custom database modifications: all it does is automate the creation of post/page content for you.
Demo
The following box contains a sample gallery imported from Facebook using this plugin. It's generated by one single "HTML magic tag" placed in the content of this page:
From Petrified Petra, posted by PederY on 6/13/2009 (Showing 16 of 60 items)
"Justin and I returned to the hotel after our late night at Petra. We decided to start bright and early the next day and get moving before the sun came up. Ladden with water, cameras and kebabs we ventured into one of the most amazing ancient cities on earth. And it would truly be a day to remember."
Generated by Facebook Photo Fetcher
"Justin and I returned to the hotel after our late night at Petra. We decided to start bright and early the next day and get moving before the sun came up. Ladden with water, cameras and kebabs we ventured into one of the most amazing ancient cities on earth. And it would truly be a day to remember."
- We started down the same path we had walked mere hours before. Some structures had be...
- A few meters down the main path we had to venture into the narrow opening between the...
- We had left the hotel way before the sun came up and were one of the first people in ...
- Almost as enchanting as the day before, and almost equally surprising, was the feelin...
- There was a neverending line of camels and donkeys and bedouins and carts with touris...
- The obligatory "me in front of Petra"-picture. The sun was still hours away from reac...
- The Treasury (or Al Khazneh) is simply amazing workmanship, thousands of years old. I...
- Petra has also been the stage for numerous movies, like Indiana Jones (which we were ...
- Camels look smart!
- Almost unbelievable that it's so intact.
- As we were leaving, tourists started pouring in from the opening in the mountain behi...
- Leaving the Treasury, we continued down the Street of Facades. Here it seemed like th...
- Camels with bedouins (or vice versa) constantly reminded us that we were far far from...
- We had done our homework and quickly left the beaten path. Our second destination was...
- In this picture it was supposed to look like we were supporting ourselves from fallin...
- Finally at the top! I bet this picture could have been used as an advertisement for s...
Instructions
- Download the latest version from here, unzip it, and upload the extracted files to your plugins directory.
- Activate the plugin via your Wordpress admin panel.
- Head over to Settings -> FB Photo Fetcher.
- Click the "Login to Facebook" button to popup a Facebook login page. Enter your information, click "Login", then close the popup. Next, click "Grant Photo Permissions." Accept the permissions in the popup and when it says "Success," close it. Finally, click "Save Facebook Session." It should now say This plugin is successfully connected with xxxxxxx's Facebook account.
- Now we need to get the ID of an album you'd like to import. Click the "Search for Albums" button; It will automatically connect to Facebook and produce a list of all the albums you can access, each with an associated ID number. Let's use the example 1234567890123456789.
- Create a new post or page and enter the following tags, replacing the example ID with the one you'd like import. Note that you must use the HTML Editor (not Visual Editor) for the tags to be recognized:
<!--FBGallery 1234567890123456789 --><!--/FBGallery--> - Click "Save", and you're done! You can now view your new album.
Customizing
Magic Tag Parameters
Let's start off with the basic code for importing a Facebook album into a page or post:
<!--FBGallery 1234567890123456789 --><!--/FBGallery-->
If you want a bit more control over how this presents the album, there are a number of parameters you can add to the opening tag, after the album ID number. These are:
- cols=#: Set the number of photos to show per row (default is 4).
- start=#: Start showing photos from the given index (i.e. to skip the first 2 photos, enter start=3)
- max=#: Limit the number of photos (i.e. to only show the first 5 photos in an album, enter max=5)
- rand=#: Show a random selection of photos from the album. This is applied after start & max, so to show 5 random photos from the entire album, enter rand=5; to randomize the first 5 items in the album, enter start=0 max=5 rand=5 (first limit the photos to the first 5, then randomize them).
- orderby=reverse: Flip the order of photos in the album (i.e. to show only the latest, you'd use "orderby=reverse max=1")
- hideHead=1: By default, albums will display their author, item count, and description prior to the first photo. Setting this will omit it that information.
- swapHead=1: Swap the order of the information in the header - author first, description second.
- hideCaps=1: By default, each photo shows an excerpt of its caption below it. Set this to omit them.
- noLB=1: By default, this plugin outputs the JS needed to setup the lightbox popups. Set this to omit it.
<!--FBGallery 1234567890123456789 cols=4 max=16 swapHead=1 --><!--/FBGallery-->
Groups & Fanpages
Thus far, we've only discussed importing personal photo albums. Here's how you'd create a gallery from a fanpage or group:
- To show photos from a specific album within a fanpage, simply input its albumID in the magic tag. Mouseover here for how to find the albumID of a fanpage album.
- To show all photos from a fanpage, add the parameter isPage=1 and replace the albumID with a pageID.
- To show photos from a group, add the parameter isGroup=1 and replace the albumID with a groupID.
<!--FBGallery 215851691826634_50508 --><!--/FBGallery-->
If you wanted to create a gallery that randomly selects 10 photos from all albums on my fanpage, you'd use:
<!--FBGallery 215851691826634 isPage=1 rand=10 --><!--/FBGallery-->
Note: See FAQ #18 if you're experiencing issues with Group albums.
Albums from PHP
If you've got a custom template or widget in which you'd like to include a gallery, you can call the function fpf_fetch_album_content() directly. It accepts the same parameters as the HTML tags above; for example:
$album = fpf_fetch_album_content( '123456789', array('cols'=>6, 'max'=>18) );
echo $album['content'];
echo "Thumbnail: " . $album['thumb'] . ", Photo Count: " . $album['count'];
Post Thumbnails
This plugin supports automatic Wordpress Post Thumbnails. If you download and install the Add From Server plugin and set a thumbnail path in this plugin's Settings page, it will copy each album's thumbnail to your local server and attach it whenever you create or update a gallery.
Item Counts
Whenever a Facebook album is inserted into a post, that post will be given the postmeta "_fb_album_size", containing the number of shown items in the album. You can reference this from your code if you wish.
Donate
Although this plugin is free to use and enjoy, it did not write itself. If you find it useful, a glass, pitcher, or keg of beer for the author would be greatly appreciated. I promise to enjoy every ounce of it :)
FAQ
Note: Numbers may not be sequential as I remove old or outdated FAQs.1. Magic Tag? Why not just call it shortcode!
I call it a "magic tag" because the way it works isn't quite the same as shortcode: Shortcode generates the content on-demand; that is, whenever a user loads a page, the shortcode will be processed and produce some html for them to view. The "magic tags" are processed when you save the page, downloading the album and inserting it as regular HTML. This avoids the need to connect to Facebook every time someone views a gallery, and also lets existing galleries continue to work even if the plugin is disabled.
2. You mentioned that it includes its own Lightbox support; will this conflict with the Lightbox2 plugin?
Nope - it checks for the presense of that plugin, and omits its own Lightbox code if present. And of course you can always disable lightboxing manually by specifying the noLB parameter to tags.
3. When trying to connect to Facebook, I get the error message "Failed to get a session secret."
Make sure you've logged in to the popup Facebook window before closing it and clicking "Save Facebook Session." The popup login window should say You may now close this window and return to the application before you close it. If it doesn't, you haven't logged in.
5. When I save my gallery pages it just says "Invalid Album ID."
Make sure there's a space after the albumID in the start tag - this wasn't a requirement in earlier versions, before I learned that ID's can contain dashes and underscores as well as numerals.
(i.e. <!--FBGallery 123456 -->, not <!--FBGallery 123456-->)
8. Albums are getting imported, but they always show as one huge column of photos.
This is a CSS issue. Most likely your theme isn't calling wp_head() in its header.php template, so Wordpress has no way to output the default stylesheet I've included.
9. I've got an idea for another feature. Could you implement it?
The main reason I wrote this plugin was for personal use. After I'd finished getting it all up and running, I later decided, "Since I've already put the effort into making it I may as well let others benefit from my work as well." So I put a nontrivial amount of extra time into creating an easy-to-use admin panel, implementing all kinds of safety checks, adding nicer presentation code, documenting it, and so forth. While I'm ecstatic to see so many people making use of it, unfortunately I can't offer more of my time for free (aside from smaller bug fixes). If you'd like to hire me to add a feature or tailor it to your needs I'd be happy to discuss it, and I'm always interested to hear your ideas. For reference, I'll keep a list of some of the cooler suggestions here:
- Generalize the code so it can be used on any PHP site, outside of Wordpress.
- Add the option to download all photos and attach them to the parent post, so they can be viewed and commented on individually (and listed by standard Shortcode).
- Get photos for Events
- Show the names of tagged users in photo pop-ups
- Show Facebook comments in photo pop-ups
- Search for albums and auto-insert the Magic Tags directly from the "New Post/Page" screen
- Schedule cron jobs to automatically re-fetch all albums
- Pagination of albums
- Localization
- Generate an "index page" for imported albums
- Allow more than one "magic tag" per post/page
Although this plugin generates the content needed to *show* your Facebook albums, the photos themselves still reside on Facebook's servers - which can be pretty unreliable at times. If some of your images won't come up, login to Facebook directly and see if those same images are working. My bet is they're not.
11. When I save a post with Magic Tags, nothing happens - the tags remain but it doesn't fetch the album.
See FAQ5. Also, make sure you're using the HTML Editor, not the Visual Editor.
12. The lightboxes aren't working - when I click an image, it just shows up in its own window.
You probably have Javascript errors on your site which are causing the browser's JS engine to abort before reaching the Lightbox code. Try debugging your site with Firebug to make sure you've fixed all other JS errors.
15. When I click a photo, it pops up partially obscured behind some other element on my page.
This is an issue with your theme's CSS. You'll need to edit your stylesheets and fix the z-indices so the lightboxed image comes up on top.
16. Is it possible to make a randomized album re-randomize its photos on every pageload?
If you create an album by calling the PHP functions directly (in a custom template), photos will be fetched and randomized each time the page is loaded. To achieve this behavior with magic tags (i.e. in your posts), you'll need to write your own filter to do so (try calling fpf_run_main() from a filter on "the_content"). However, as this will be pretty resource-intensive and will make your pageloads dependent on Facebook itself, I don't recommend it - a better idea would be to setup a cron job to re-fetch the album periodically (i.e. once an hour). This maybe added to a future version, but for now I'm afraid you're on your own.
17. When I activate the plugin, I get an error like "Parse error: syntax error, unexpected..."
This plugin requires PHP5; you're probably still using PHP4.
18. Group albums aren't working - they always show 0 items, even for groups that are completely open.
It would appear that Facebook's old REST API doesn't support their new group format, so while old groups will continue to work, you may experience problems with new ones. The only fix I've been able to find would be a complete API upgrade, a nontrivial task which I unfortunately cannot do at this time. If anyone with Facebook API knowledge manages to find a workaround I'd be more than happy to implement it, otherwise I'm afraid it'll have to remain as-is until there's a lull in paid jobs that make time for the upgrade :)
19. I'm getting "Fatal error: Uncaught exception ‘FacebookRestClientException’."
Try re-authorizing with Facebook by clicking "Change Facebook Account" in the admin panel. If that doesn't fix it, it's possible that one of Facebook's servers is having an issue - please wait a few hours and give it another try.
20. Is there a way to create an "index page" that links to all my imported Facebook albums?
Sure, but it requires custom coding. You can implement this by creating a page template that iterates through and lists its child pages, then make your albums children of that page. For help, please see the WP docs.
21. The plugin only seems to work with albums that have less than X-number of photos.
Most likely your webhost has set too low of a "max_execution_time" in php.ini, or the server is too overloaded and is timing out. You can determine this by checking your logs (or contacting your host if you don't know how).
100. Something else isn't working as you've described!
Improperly coded themes and conflicting plugins are two of the most common sources of error, so if you're confident you've followed the directions above and something still isn't working, please try it again with all other plugins disabled and with the default Wordpress theme. If that works, you should be able to pinpoint the source of the issue by reactivating them one at a time.
Feedback/Support
So, you've setup the plugin and it isn't doing what you expect. What now? The first thing you should do is carefully reread all the documentation above, paying special attention to the FAQs; 99% of support questions are solved by the solutions already offered above.
Still no joy? If you need personal help, you can get paid support by donating at least $20USD to the author:
You may then email me your question and I'll get back to you as soon as I can. It will improve the process if your message contains the following information:
- A clear explanation of the problem: When does it happen? When doesn't it happen? What do you see?
- What have you tried? Did you disable all your other plugins? Did you try the default theme?
- Provide a link to the gallery that isn't working, if available.
- Provide the exact tags you're using, if available.
Download testking mcdba tutorials to learn about Wordpress. Our testking mcdst guide and testking mcp demos will provide complete information on WP plugins.



















I tried it with that ID and it worked exactly as expected:
<!– FBGallery 180808161965378 isPage=1 –> <!– /FBGallery –>
<Page Link Removed>
I copied & pasted the code into the page, just as you wrote above, in the HTML section of the page. However I’m still getting this on the plugin page:
Search for Albums
Userid 180808161965378 not found.
Here’s the test page: http://www.foresthillsbusinessassociation.com/metro-cruise-warm-up-pictures-2011/
I’ve got my ID number for the connection to FB & it says that that part is successful. What could I be doing wrong?
Um….you’re saying two different things here. Pasting a tag in the HTML of a post/page has nothing to do with the search function of the admin panel…so I’m really not sure what you’re doing.
It realy work. But! Only for albums with 1-2 fotos.
When i press Save Post in my admin panel, i have only part of code insted of . I have approximately 17 line of code not more.
How fix it?
Um…no, even the demo above proves that it works with more than 1-2 photos
I myself have used it with the maximum of 200.
If there’s no specific error message, probably your server is timing out or something – you’ll have to check your error logs.
Thanx for your replay. Maybe.
But its very strange. Is it ok that your magictag in post is converted to long code (img, script, etc), when i press Save button?
It looks like wordpress dont have enough time and reloads too fast. So i have only part of long code (not magictag) in my post.
>>Is it ok that your magictag in post is converted to long code (img, script, etc), when i press Save button?
Yep, that’s what it’s supposed to do – it fetches the album info and auto-writes html to display it (in your post content).
>>It looks like wordpress dont have enough time and reloads too fast. So i have only part of long code (not magictag) in my post.
…like I said: “probably your server is timing out or something – you’ll have to check your error logs.”
Hi Justin, I have been looking for an app like this for joomla, I couldn’t find it
, so I was wondering if I can use some (the majority XD) of your code to make a plugin app for Joomla, i would use it for a personal non-profit web site, and if it works ok, I will publish it on the joomla-extensions site.
thanks in advance.
Atte. Jose Hernandez
Can you explain the following error at all please?
I am using the following tag to create the gallery (taken from the FPF settings):
<!–FBGallery 3209671460218306862 –><!–/FBGallery–>
When I save the post I get the following error:
Missing gallery end-tag.
Warning: Cannot modify header information – headers already sent by (output started at /home/sportc/domains/courtenaysport.co.uk/public_html/blog/wp-content/plugins/facebook-photo-fetcher/_output_gallery.php:79) in /home/sportc/domains/courtenaysport.co.uk/public_html/blog/wp-includes/pluggable.php on line 934
I cannot understand this because this plugin has worked on my blog previously, but now I have error.
I have disabled ALL other plugins, and tried the default theme. I am using WP 3.2.1 and PHP5. I have uninstalled and reinstalled the plugin and WP 3.2.1
Have I missed something obvious?
Thanks in advance
@Jose Hernandez: Sure! Please just be kind enough to give clear credit to the original (i.e. in the docs/admin panel/footer, like I’ve done)…but you’re welcome to port it over if you like
@Mark: No idea. I just copied your exact tag and it worked as it’s supposed to (album: Brands Hatch 2011 Production Touring Cars). Also, that’s the first I’ve ever heard of anything like that in the 1.5years since the plugin was made… :/
Justin,
Thank you so much for your work. It works worked very easily for my personal profile and other personal user profile facebook photos and albums. I have tried unsuccessfully to pull all the photo albums from our fanpage into one page with the short code as in the example you gave in the customization section.
Our fanpage is http://www.facebook.com/BrysArtRewardsKids
the Facebook ID as I understand it is 160593783992636
Searching from the settings within the plugins admin retrieves only errors.
Any help or example you could give me is very appreciative.
Upon getting this to work you can definitely expect my donation.
Thanks,
Russell
As the Admin panel says immediately above the search box:
“Note that searching only works for personal albums; for groups and pages, see “Customizing” in the plugin documentation.”
The last bullet point of requested information under “Feedback/Support” above:
“Provide the exact tags you’re using”
Still working on this from 9/21/11…
I’ve copied and pasted your code…and corrected the syntax in WP (it changed the double dash to a single dash & added some extra spaces). When I re-fetch the albums in pages, which is where my code resides, I get this:
Checking 9/12: Metro-Cruise Warm-up Pictures – 2011……No gallery tag found.
The code I’m using looks like this:
What am I missing here?
Thank you so much Justin, i’ll let you know when i finish, of course i’ll leave a large space with details about the original app, it’s the lest I can do. thanks again.
@Kim: Honestly, I really have no idea – as I said the tags do work as they’re supposed to for me, and nobody has ever reported an issue like this…
If you need me to debug it for you, you can provide me a login to edit the page and try it myself. However, please note that as of today I’m no longer offering free support for individual users (i.e. issues that aren’t broad-spectrum enough to affect more than one person). I will of course continue to maintain the plugin and fix legitimate bugs as always, but will no longer be debugging individual sites or themes for free. Please see the updated documentation above.
(This has actually been a long-planned move due to the overwhelming time I spend replying to requests; I just put it on the backburner as there was a relative lull and I didn’t have time to update the docs until now).
Your plugin is awesome! It works flawlessly for me, including the isPage=1 variable. Brilliant!
How about auto refetch albums when page is loaded?
FAQ16
When using isPage=1 the plugin seems to just pull every image associated with the page, and disregard any albums they are grouped into on Facebook. Is this something that can be changed? I don’t really want to load all 2,000 pictures from the page at once.
Please read the documentation above where this is already discussed.
(Also, did you miss the part about discontinuing free support, or simply choose to ignore it?)
Hi There,
I don’t get a list of photo albums when I press “Search”
I’ve tried to look at the code, but it’s beyond me at this stage! please help
Nevermind, it works now
sorry for the confusion.
I was going to ask something about the plugin, but after reading all your comments, Justin, I must ask… How is the energy vampire stuff working for you?
@matt: np
@Dan: Is that supposed to be a snide comment about the fact that, after spending dozens of hours developing a plugin for free and dozens more carefully documenting every relevant question, I sometimes get annoyed at the fact that I *still* end up spending hours every week answering the same questions over & over because people can’t be bothered reading the docs?
Fantastic plugin, Justin, works like a charm. My application requires slurping specific albums from fan pages. The comment that you can’t do it “at the moment” — does that mean it’s in development? : )
No, I’m not actively developing the plugin at this time.
Hi
I’m using your plugin for a lost and found pets site. Is there any way that one can fetch the date of a facebook photo and not just the description? I would gladly pay to have this feature!
Thanks
Joan
Hi Joan,
E-mailed you.
Hi Justin, great job on the plug-in! I had a general question that I couldn’t find the answer for. I see some references to ‘re-fetching’ the album. Does this mean that as new pictures are added in FB, they will not dynamically update on the site? I created a gallery, viewed it on my wordpress site and then went back and updated photos on my FB pages. I refreshed my wordpress and the new pics had shown up there. Thanks in advance for your time and helping me understand the ‘re-fetch’ concept!
Unless you’re using it directly from PHP, it does not refresh the albums when you update on Facebook – you have to re-fetch yourself. See FAQ1 for how the plugin works.
I thought that’s what the case was, but I was unsure why photos were dynamically showing up on the wordpress site without me re-fetching.
Something else must be doing it. That’s not possible with this plugin alone.
It is a curiosity! I wonder if it could do with the session information that is saved while inputting the log in information and granting access for the app the grab the photos.
Thank you for the clarification, and again…great plug in.
I am pretty excited to have an alternative to Fotobook. That plugin works well but not a perfect fit for my needs.
I am wondering, did the CRON capability ever get added to this plugin? Or is it easy just to set one up and just run the update script?
Thanks for the plugin (and I know support is not free, just a question:)
RTBOP
@Luke: …Huh?
@Online Programs: Nope, I haven’t implemented it yet, but as I’m sure it would be fairly quick I’d be willing to do so should you be interested in contracting me for an hour or two of work.
I have already started writing it.. for amusement and a challenge. You know who I will call if I get stuck! I just realized you are a traveling coder as well. Gotta love the Internet
I have been out of the US for 2 years now. Malta and Lichtenstein are next on my list
RTBOP
Nice! Never been to either of those myself, tho I do plan to head back to Europe next summer
Greetings Justin,
Thanks for a great plugin. Easy install and setup. However, I am having a minor problem and would like to know your time frame to respond to a paid support request given your nomadic lifestyle. Thanks, in advance, for your attention to this inquiry.
Best regards,
“ping it”
I almost always have Internet access, even in remote locations (Cambodia at the moment) so questions are generally answered pretty quickly
Thanks, Justin, for your prompt response. I will submit a paid request next week. I have the app working, but it only retrieves 2/3rds of the photos in the Facebook Group Album. Not sure if this is a app issue or caused by the web hosting service (1and1) Looking forward to your assistance. Best regards, Gordon
This is likely due to Facebook’s security/permissions policies, which change ALL the time – are the photos that it can’t access uploaded by one particular user? If so, that user probably just has their privacy settings set such that the photos can’t be obtained (guessing).
Hey all,
One of my users was just kind enough to point out that it actually *is* possible to import individual albums from within a fanpage using the plugin as-is; you simply need to get the direct albumID of that album.
The instructions above have been updated to reflect this.