You are here

function fb_preprocess_user_picture in Drupal for Facebook 7.4

Implements hook_preprocess_user_picture().

Use a facebook profile picture if facebook ID known, and no local picture.

File

./fb.module, line 541

Code

function fb_preprocess_user_picture(&$variables) {

  // Note $variables['user_picture'] will contain the site-wide default even if user has not uploaded a picture.
  if ((empty($variables['user_picture']) || empty($variables['user']->picture)) && !empty($variables['account']->name) && ($pos = strpos($variables['account']->name, '@facebook'))) {
    $fbu = substr($variables['account']->name, 0, $pos);
    if ($fbu) {
      $variables['user_picture'] = theme('image', array(
        'path' => '//graph.facebook.com/' . $fbu . '/picture',
      ));
    }
  }
}