Hello All!,
Does anyone know how to add the profile photo for node author using content template?
I tried adding: print $node->user->picture
but all I got was: files/pictures/picture-1.jpg.
It’s showing the file path to the picture instead of the actual picture itself.
How do I get it to show the picture?

Best Regards

Comments

yuriy.babenko’s picture

---
Yuriy Babenko | Technical Consultant & Senior Developer
http://yuriybabenko.com

troym559’s picture

Thanks for the reply. I checked out those links but I didnt really find the answer to my quesiton.
Is there somthing that needs to be added to the php code? Or is there another setting that i need to enable to make that code print the user picture instead of the file path to the user picture?
Thanks again for the reply.

yuriy.babenko’s picture

You have the image path - just add an HTML image tag.

    print '<img src="'.base_path().$node->user->picture'" alt="User picture" />';

---
Yuriy Babenko
www.yubastudios.com
My Drupal tutorials: http://yubastudios.com/blog/tag/tutorials

---
Yuriy Babenko | Technical Consultant & Senior Developer
http://yuriybabenko.com

troym559’s picture

Adding that code makes all the rest of the content on the page go bye bye. The page is left completly blank and still no author photo. I copied and pasted the code into my content template just as it was then saved it. Didn't seem to work. Am i missing somthing?

troym559’s picture

My content type is a usernode type added using the usernode module. I am also using nodeprofile module so the nodeprofiles are being displayed at the usernode. My template code for the usernode is very simple.
print $body displays all the nodeprofiles ralated to the user just fine. But if i enable user pictures on posts then it repeats the user pic on each nodeprofile on the page. Which looks kind of silly having the same picture 5 times. So I disabled the user photo on posts setting.
Now I want to add the author of the usernodes pic to show up in the top of the usernode using content templates so that when viewing the page you would only see the author’s picture 1 time at the top of the page.
I went to my content template and selected the Body Variable: "$node->picture" that generated the code: " print $node->user->picture " Into my content template body. Now my template code is: " print $node->user->picture
print $body ". But the author picture is not showing up the only thing that shows is the file path to the author pic.
Please help.
Thanks

rc2020’s picture

Hey,

Did you or anyone else happen to find a solution to this problem yet? This would be quite interesting to accomplish...thanks.

baxterjones’s picture

i had this same problem a few months ago, what i did:
select the default template of drupal (garland), select the setting on the "configure" page of the template, tick "User pictures in posts"...
check the "Global settings" page and tick boxes under "Display post information on" for the relevant content types, and under "Toggle display" tick "User pictures in posts" box.

from there i'm sure you can work out what is missing in your template. if not go to drupal-url/sites/all/themes/your-theme-url/node.tpl.php and search for a line something very similar to ' print $picture ', that should display the image at the right place.

if that still doesn't work, then make sure the users have picture support (admin/user/settings) then check the person who posted the node has an image uploaded to the profile...

any more help needed?

ericinwisconsin’s picture

I found this one here. It works:

<?php 
$owner = user_load(arg(1));
print theme('user_picture', $owner); 
?>

However, it gives you the following error on the contemplate template page:

warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /xxx/sites/all/modules/imagecache_profiles/imagecache_profiles.module on line 41.

If someone knows what to change to get rid of the error, I'd greatly appreciate it.

diegui69’s picture

Yo lo que queria es meter dentro de un tipo de noticia la foto del autor, por medio de contect template. lo cosengui asi

print theme('user_picture', $node);

espero que os ayude.

Un saludo.

Lucasljj’s picture

*edit*
Thanks!!! that's what I want, thank you!