0

tried what igorik said on drupal.org == http://drupal.org/node/609454#comment-2172258 Placed user-picture.tpl.php in my theme directory and replaced code inside it:

<div class="picture">
<?php print $picture; ?>
</div>

to:

<?php
$img_url = $content_profile->get_variable('profile', 'field_photo');
print l(theme('imagecache', 'msg_profile_pic', $img_url), 'user/' . $account->uid );
?>

but all what im getting after these actions is WSOD... set to display errors true in index.php, but still can't see any errors. Help me guys! Thanks

3 Answers 3

1

To find out errors in WSOD you can look at you Apache Error Log, in Ubuntu you can execute tail -f /var/log/apache2/error.log and you will see the php error.

It's pretty sure the problem come from $content_profile which doesn't seem to be instanciated and thus don't carry the whole content profile object. You can load it using content_profile_load.

0

You might want to look at the ImageField Avatar module which is able to automatically synchronize images from a content_profile CCK ImageField to the core drupal user picture field.

1
  • Thanks, but i won't use a module for this task. I want this programmatic done. May 18, 2011 at 8:17
0

By default, $content_profile variable is NULL in user-picture.tpl.php file, while you don't explicitly load its contents with content_profile_load() function or make this variable available in this template too. (Citing from the official readme about the places where this variable is available: "The $content_profile variable is available in the page, node, comment, user_name, user_profile, user_signature, search_result and some other templates.")

I think it's a better solution to create your own user-profile.tpl.php (you should copy it from /modules/user directory to your own theme's templates directory, and delete theme registry cache after that), where the $content_profile variable is already set, and print the customized user profile picture in this one.

When you use the Content Profile module's get_variable() function, you usually get an array or NULL (if the variable doesn't exist).
If it's an image field (and you query its content with e.g. $content_profile->get_variable('profile', 'field_photo');), the content of the variable looks something like this:

array (
  0 => 
  array (
    'filename' => 'default_avatar1.gif',
    'filepath' => 'sites/default/files/imagefield_default_images/default_avatar1.gif',
    'filemime' => 'image/gif',
    'source' => 'default_image_upload',
    'destination' => 'sites/default/files/imagefield_default_images/default_avatar1.gif',
    'filesize' => 5711,
    'uid' => '1',
    'status' => 1,
    'timestamp' => 1320633662,
    'fid' => '54',
    'default' => true,
    'nid' => '446',
  ),
)

So in your case, you should rather do something like this (in the appropriate place in user-profile.tpl.php file):

$user_profile_photo = $content_profile->get_variable('profile', 'field_photo');

print l( theme('imagecache', 'msg_profile_pic', $user_profile_photo[0]['filepath'], 'just a test image', 'test image'), 'user/'.$account->uid, array('html' => true) );

Of course, 'field_photo' must be a valid CCK field (previously set in Content Profile's fields), and 'msg_profile_pic' must be a valid ImageCache preset.
Just tested, it works on my site.

Your Answer

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

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