You are here

function template_preprocess_author_pane_user_picture in Author Pane 7.2

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

Process variables for author-pane-user-picture.tpl.php.

The $variables array contains the following arguments:

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

See also

author-pane-user-picture.tpl.php

File

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

Code

function template_preprocess_author_pane_user_picture(&$variables) {
  $variables['picture'] = '';
  if (variable_get('user_pictures', 0)) {
    $account = $variables['account'];
    if (!empty($account->picture) && !empty($account->picture->uri)) {
      $filepath = $account->picture->uri;
    }
    elseif (variable_get('user_picture_default', '')) {
      $filepath = variable_get('user_picture_default', '');
    }
    if (isset($filepath)) {
      $alt = t("@user's picture", array(
        '@user' => format_username($account),
      ));

      // If the image does not have a valid Drupal scheme (for eg. HTTP),
      // don't load image styles.
      if (module_exists('image') && file_valid_uri($filepath) && ($style = !empty($variables['picture_preset']) ? $variables['picture_preset'] : '')) {
        $variables['picture'] = theme('image_style', array(
          'style_name' => $style,
          'path' => $filepath,
          'alt' => $alt,
          'title' => $alt,
        ));
        $variables['imagecache_used'] = TRUE;
      }
      else {
        $variables['picture'] = theme('image', array(
          'path' => $filepath,
          'alt' => $alt,
          'title' => $alt,
        ));
        $variables['imagecache_used'] = FALSE;
      }
      if (!empty($account->uid) && user_access('access user profiles')) {
        $options = array(
          'attributes' => array(
            'title' => t('View user profile.'),
          ),
          'html' => TRUE,
        );
        $variables['picture_link_profile'] = l($variables['picture'], "user/{$account->uid}", $options);
      }
      else {
        $variables['picture_link_profile'] = FALSE;
      }
    }
  }
}