Moodle中的个人资料图片的路径? [英] Path to profile picture in Moodle?

查看:382
本文介绍了Moodle中的个人资料图片的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在moodle网络应用程序中编程,正在寻找检索用户个人资料图片的路径。



我假设我可以在数据库,但我只得到mdl_user.picture和mdl_user.imagealt,所以实际上我知道谁上传了一张图片,但不能得到他/她上传的图片。





感谢您的帮助,



OM

p>

解决方案

如果你想要的图像标签,你可以使用print_user_picture(),并传递你从数据库中得到的用户对象。您还可以指定图像的大小。因此,为当前用户打印完整大小的用户图片

 全局$ USER,$ COURSE; 

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

否则,如果你只需要url,你就做这样的事情

  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,用户');
}


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

解决方案

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');
}

这篇关于Moodle中的个人资料图片的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆