User profile picture URL in Moodle 2.8

Re: User profile picture URL in Moodle 2.8

by Conn Warwicker -
Number of replies: 2
Picture of Core developers Picture of Plugin developers

The number in the redirected page is the id of the mdl_context record for that user.

Example:


If I go to my picture on my localhost

http://local/user/pix.php/5/f1.jpg

"5" is the ID of my user.


That looks up the context of the user in the mdl_context table and returns the record:

id: 17

contextlevel: 30

instanceid: 5

path: /1/17

depth: 2


Then it uses that id of the context record "17" to build the URL to the image, using this method:

$url = moodle_url::make_pluginfile_url($usercontext->id, 'user', 'icon', null, '/', $image);


So it redirects me to:

http://local/pluginfile.php/17/user/icon/f1

Average of ratings: Useful (3)
In reply to Conn Warwicker

Re: User profile picture URL in Moodle 2.8

by Federica Marra -

Hi Conn and Richard,

many thanks for your support and explanation!
In the end I managed to get the pictures in the report with the sql:

SELECT
    -- User.
    u.firstname 'FirstName', u.lastname 'LastName'
   , u.picture, u.id 'UserId'


and in the template:

<img src="http://www.utzacademyonline.com/user/pix.php/userid/f1.jpg">


Special thanks for the sql/template goes to @Matteo Scaramuccia


In reply to Federica Marra

Re: User profile picture URL in Moodle 2.8

by Alex Egea Guirado -

Hello Federica,Conn and Richard

while I'm trying to get a list of students with photography but can not find the way. configurable block proved to report but I missed the SQL statement to remove the photographs since they are encrypted.
You got it? Could you help me to do so.
You need to make lists in Word or Excel with the name and photograph
Thank you,


Alex