My field_image is not rendering on user-profile.tpl. I have the following code (two different ways to render for testing):

    $image = field_get_items('user', $user, 'field_image');
    $output = field_view_value('user', $user, 'field_image', $image[0], array(
      'type' => 'image',
      'settings' => array(
        'image_style' => 'header_image_160x160',
    print render($output);

This produces the following in html:

<img src="https://coinme.io/sites/default/files/styles/header_image_160x160/public?itok=f31sbmSd" width="160" height="160" alt="">

I get the dead image logo. It is missing the final part of the file structure. And this is how I normally render:

$to_render = field_view_field('user', $user, 'field_image', array('settings' => array('image_style' => 'header_image_160x160'))); print render($to_render);

This is showing the default image, even though the image does exist:


I have the same field in a content type which is rendering correctly (only difference being the $user user -> $node node.

<?php $to_render = field_view_field('node', $node, 'field_image', array('settings' => array('image_style' => 'header_image_160x160'))); print render($to_render);?>

So it appears that when using user-profile specifically is the issue. I have also tried adding a new field type and same effect. Any suggestions?

Thanks, Paul.

  • Are you sure $user is in scope and that the field name is field_image? It looks like one of those things is causing the actual filename to be unavailable. Commented Jan 12, 2014 at 11:07
  • 1
    @DavidThomas I just came to the same conclusion. It didn't occur to me until I did a print_r($user) and got my logged in user. Thank you for getting involved.
    – Paul
    Commented Jan 12, 2014 at 11:30

1 Answer 1


The answer was simple: $user is the logged-in user; since the logged-in user didn't have a profile image, I got the default image.

Elsewhere on the page, I wasn't using $user, but all the variables whose ID started with $field_, so it looked like I was using the right variable. This fixed it.

$account = $elements['#account'];

Then, I updated $user to $account.

$to_render = field_view_field('user', $account, 'field_image', array('settings' => array('image_style' => 'header_image_160x160'))); print render($to_render);  

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.