Hiding Private Photos
Problem
How do I know whether I can show a photo to a user?
Solution
Use the fb:if-can-see-photo
and specify a photo ID (pid
). The simplest form is:
<fb:if-can-see-photo pid="12345"> <fb:photo pid="12345" /> </fb:if-can-see-photo>
For more information on fb:photo
, see Embedding Facebook Photos.
Discussion
The default behavior of fb:if-can-see-photo
is to check for
permission for loggedinuser
, but you can specify a
uid
for a different user to check
that person’s permissions instead. As always, you can include fb:else
to display an alternate image:
<fb:if-can-see-photo pid="12345"> <fb:photo pid="12345" /> <fb:else> <img src="images/default.jpg" alt="Can't see this!" /> </fb:else> </fb:if-can-see-photo>
Get Facebook Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.