Worth a Thousand Words: Profile Pictures

Problem

Profile pictures are awesome because they’re so easy to recognize and they really draw people in! How can I display someone’s pic?

Solution

The fb:profile-pic tag will display the Profile picture for the user specified by the uid parameter. The simplest form is:

<fb:profile-pic uid="12345"/>

Discussion

In addition to the uid, there are two optional parameters, listed in Table 6-3.

Table 6-3. Parameters for fb:profile-pic

Name

Type

Default value

Description

uid

int

N/A

The Facebook user ID (uid) of the user or Page whose pronoun you want to show. You can also use loggedinuser or profileowner. This is the only required field.

linked

bool

true

Link to the user’s Profile.

size

string

thumb

Size of image to display (see the upcoming list).

Differently sized pics can be hugely useful in different scenarios. Using my current Profile picture (taken by my good friend Will Pate), the following list shows a breakdown of the options (note that you can use the short form listed in parentheses):

thumb (t): 50 pixels wide
image with no caption
small (s): 100 pixels wide
image with no caption
normal (n): 200 pixels wide
image with no caption
square (q): 50×50 pixels

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.