You are here

function template_preprocess_author_pane_user_picture in Author Pane 6.2

Same name and namespace in other branches
  1. 7.2 author_pane.module \template_preprocess_author_pane_user_picture()

Preprocesses template variables for the author pane picture template.

Available variables (All optional except 'account'): $variables['account']: User account object. $variables['caller']: String identifying who called the theme function. Usually the name of the module but doesn't have to be. $variables['picture_preset']: Imagecache preset to use to format the user picture.

File

./author_pane.module, line 231
Gathers information from user related modules into one template.

Code

function template_preprocess_author_pane_user_picture(&$variables) {
  $variables['picture'] = '';
  $account = $variables['account'];

  // Get the imagecache preset, if any.
  $preset = !empty($variables['picture_preset']) ? $variables['picture_preset'] : '';

  // If user pictures are enabled...
  if (variable_get('user_pictures', 0)) {

    // Get the user's avatar if they have one or the default picture if exists.
    if (!empty($account->picture) && file_exists($account->picture)) {

      // We only want to get the full URL if not using imagecache.
      $picture = !empty($preset) && module_exists('imagecache') ? $account->picture : file_create_url($account->picture);
    }
    elseif (variable_get('user_picture_default', '')) {
      $picture = variable_get('user_picture_default', '');
    }

    // If we have a picture...
    if (isset($picture)) {

      // If there's a preset set and imagecache is enabled...
      if (!empty($preset) && module_exists('imagecache')) {

        // Toss the picture over to imagecache for sizing
        $alt = t("@user's picture", array(
          '@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous')),
        ));
        $variables['picture'] = theme('imagecache', $preset, $picture, $alt, $alt);
        $variables['imagecache_used'] = TRUE;
      }
      else {

        // Just run the picture through theme_image. Note that we don't link
        // the picture here since it doesn't make sense for many uses of AP.
        // If the picture needs to be linked, it can be done in the template.
        $alt = t("@user's picture", array(
          '@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous')),
        ));
        $variables['picture'] = theme('image', $picture, $alt, $alt, '', FALSE);
        $variables['imagecache_used'] = FALSE;
      }
    }
  }
}