Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path to profile picture in Moodle?

I was programming something in moodle web-application and was looking into retrieving the path of the user profile images.

I assumed I could find the path somewhere in the database but I only got to mdl_user.picture and mdl_user.imagealt, so practically I know who has uploaded a picture but can't get to which picture he/she uploaded.

Is there a way to get it from the database?

Thanks for your help,

OM

like image 682
OM The Eternity Avatar asked Jul 27 '11 06:07

OM The Eternity


People also ask

How do I change my profile picture on Moodle app?

To change your picture, log into Moodle then click your name in the top right of the screen → Profile → Edit Profile (from the gear icon) and scroll down to the User Picture area. Drag your desired image file into the New Picture box.

How do I add a profile picture in my user account as a instructor?

To upload a new profile picture, click the Upload a Picture tab [1], then click the choose a picture link [2]. You can also drag a picture from your desktop and drop it into the uploader.


2 Answers

in moodle 2.0 you can use this

global $USER,$PAGE; 
$user_picture=new user_picture($USER);
$src=$user_picture->get_url($PAGE);
like image 27
aladein Avatar answered Oct 14 '22 18:10

aladein


If you want the image tag you can use print_user_picture() and pass the user object that you got from the database. You can also specify the size of the image. So to print the full size user picture for the current user you could do

global $USER, $COURSE;

print_user_picture($USER, $COURSE->id, null, true);

Otherwise if you need just the url you have do do something like this

require_once($CFG->libdir.'/filelib.php');

$size = array('large' => 'f1', 'small' => 'f2');

$src = false;
if ($user->picture) {
   $src = get_file_url($user->id.'/'.$size['large'].'.jpg', null, 'user');
}
like image 80
matthewdaniel Avatar answered Oct 14 '22 19:10

matthewdaniel