All pastes #951223 Raw Edit

Stuff

public text v1 · immutable
·published 2008-03-21 03:56 UTC
rendered paste body
template.php has this

function phptemplate_user_picture($account, $size = '25x25') {
  if (arg(0) == 'user' && is_numeric(arg(1))) {
    $size = '100x100';
  }

  if (variable_get('user_pictures', 0))  {
    if ($account->picture && file_exists($account->picture)) {
      if ($size == '100x100') {
        $maxsize_icon = array('w'=>100, 'h'=>100);
        $info = image_get_info($account->picture);
        if ($info['height'] < $maxsize_icon['h']) {
          $maxsize_icon['h'] = $info['height'];
        }
        if ($info['width'] < $maxsize_icon['w']) {
          $maxsize_icon['w'] = $info['width'];
        }
        $newpicture = dirname($account->picture) . '/picture-' . $account->uid . '.' . $info['extension'];
        if (!file_exists($newpicture) || (filectime($newpicture) < filectime($account->picture))) {
          image_scale($account->picture, $newpicture, $maxsize_icon['w'], $maxsize_icon['h']);
        }
        $picture = file_create_url($newpicture);
      }
      else if ($size == '25x25')  {
        $maxsize_tile = array('w'=>25, 'h'=>25);
        $info = image_get_info($account->picture);
        $newpicture = dirname($account->picture) . '/picture-small-' . $account->uid . '.' . $info['extension'];
        if (!file_exists($newpicture) || (filectime($newpicture) < filectime($account->picture))) {
          image_scale($account->picture, $newpicture, $newpicture, $maxsize_tile['w'], $maxsize_tile['h']);
        }
        $picture = file_create_url($newpicture);
      }
      else {
        $picture = file_create_url($account->picture);
      }
    }
    else if (variable_get('user_picture_default', '')) {
      $picture = variable_get('user_picture_default', '');
    }
    if (isset($picture)) {
      $alt = t('@user\'s picture', array('@user' => $account->name ? $account->name : variable_get('anonymous', 'Anonymous')));
      $picture = theme('image', $picture, $alt, $alt, '', false);
      if (!empty($account->uid) && user_access('access user profiles')) {
        $picture = l($picture, "user/$account->uid", array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);
      }

      return "<div class=\"avatar\">$picture</div>";
    }
  }
}

Then you do this:

<?php if ($picture) { print theme('user_picture', $node, '25x25'); }?>

Or this

<div class="picture"><?php print theme('user_picture', $user, '100x100'); ?></div>