Displaying the facebook profile picture in the WP-FB AutoConnect widget?

Hi JanoChen,

WP-FP-AutoConnect create a function that gets the Facebook Profile image and outputs it as an avatar.

The function is jfb_wp_avatar and it can be added to your template.

You have to enable the option in the plugin settings.

Here is how the function is defined in the plugin:

/**
  * Optionally replace WORDPRESS avatars with FACEBOOK profile pictures
  */
if( get_option($opt_jfb_wp_avatars) ) add_filter('get_avatar', 'jfb_wp_avatar', 10, 5);
function jfb_wp_avatar($avatar, $id_or_email, $size, $default, $alt)
{
    //First, get the userid
    if (is_numeric($id_or_email))       
        $user_id = $id_or_email;
    else if(is_object($id_or_email) && !empty($id_or_email->user_id))
       $user_id = $id_or_email->user_id;
    else if(is_string($id_or_email))
       $user_id = get_user_by('email', $id_or_email ); 

    //If we couldn't get the userID, just return default behavior (email-based gravatar, etc)
    if(!isset($user_id) || !$user_id) return $avatar;

    //Now that we have a userID, let's see if we have their facebook profile pic stored in usermeta
    $fb_img = get_usermeta($user_id, 'facebook_avatar_thumb');
    
    //If so, replace the avatar! Otherwise, fallback on what WP core already gave us.
    if($fb_img) $avatar = "<img alt="fb_avatar" src="https://wordpress.stackexchange.com/questions/10327/$fb_img" class="avatar avatar-{$size} photo" height="{$size}" width="{$size}" />";
    return $avatar;
}