I have Statuses Module installed on one of my site. I have created a view to display the status along with the user picture and the following comments.

The view displays the user picture along with the statuses, but the image style used is the default 'thumbnail' style. I have created my own image style for displaying these images.

Usually in a view when images are added we get a option by default to add image style to it. But in this case I dont have that option.

After a bit of searching I found the following code in the statuses.module to display the user picture:

function statuses_display_user_picture($account, $preset = NULL) {
  drupal_add_css(drupal_get_path('module', 'statuses') .'/resources/statuses.css');
  $image_vars = array('account' => $account);
  if (!empty($preset) && module_exists('imagecache_profiles')) {
    $image_vars['user_picture_style'] = $preset;
  return theme('user_picture', $image_vars);

How do I override this code to display the image with my choice of 'image style'.

1 Answer 1


Use hook_preprocess_user_picture(). See template_preprocess_user_picture().

Here a sample code:

 * Implements hook_preprocess_user_picture().
 * @see template_preprocess_user_picture().
function example_preprocess_user_picture(&$variables) {
  $style = 'your_style';

  $account = $variables['account'];
  if (is_numeric($account->picture)) {
    $account->picture = file_load($account->picture);
  if (!empty($account->picture->uri)) {
    $filepath = $account->picture->uri;

  if (isset($filepath)) {
    $alt = t("@user's picture", array('@user' => format_username($account)));
    $variables['user_picture'] = theme('image_style', array('style_name' => $style, 'path' => $filepath, 'alt' => $alt, 'title' => $alt));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.