get user profile picture url by userid

Re: get user profile picture url by userid

by Song Kim -
Number of replies: 0
for anyone who needs the answer to the question, this this what i got:

// getting the user object by userid.
$user_object = core_user::get_user(2);

// this is some conditions i've given. it's not required.
// size is the size of the picture in px. link is the a tag links to user's profile wrapping around the picture. class is the html class of the img element.
// there are more of these, but you have to look at user_picture class in outputcomponents.php
$conditions = array('size' => '240', 'link' => false, 'class' => '');

$person_profile_pic = $OUTPUT->user_picture($user_object, $conditions);
echo $person_profile_pic;

*remember* this will return html code. not just the url.

i chose to use the user_picture class because i was going to put it in an img element anyway.

if you truely want the url and nothing else, you should use the userpictureurl from FilterCodes plugin which was recommended by Mr Michael Milette.

just remember to set the f$1 to the size you need.
f1 for small
f2 for even smaller
f3 for large
im not sure why it's like this, but it is what it is.