Databases: Need to find user picture location in the database

Databases: Need to find user picture location in the database

by Mignonne Davis -
Number of replies: 6

this question sounds very similiar to the last one, but in this case, I really do need to know where in the database the user picture/icon is stored.  I think it is just a pointer and not the actual picture, so one can pass the right value to pluginfile.php  (i.e. //nameofsite.com/pluginfile/XXXX/user/icon  But where do I get the XXX for a particular user???)

I've looked in all the possible places in the database that relate 'user" but still can't find it.  I can just use the OUTPUT->user_picture because I don't want to output it right then, I want to store it in a log file to output later.  Any ideas?

Average of ratings: -
In reply to Mignonne Davis

Re: Databases: Need to find user picture location in the database

by Johnathan Au -

Here, do this:

1. Retrieve ID of user.

2. Put ID of user in URL like this:
nameofsite.com/user/pix.php/'.$id.'/f1.jpg 

And there you have it. Easy.

Average of ratings: Useful (1)
In reply to Johnathan Au

Re: Databases: Need to find user picture location in the database

by Mignonne Davis -

That WAS easy!  Beautiful, thanks so much!

In reply to Johnathan Au

Re: Databases: Need to find user picture location in the database

by Peter Easton -

Hi Johnathan,

Thanks works great in previous versions of moodle but in Moodle 2.3.2+ they have changed the url to the picts and I'm having a problem making the connection between the two

this use to work:
http: //my.site.com/uesr/pix.php?file=4/f1.jpg

now it wants to be:
http://my.site.com/pluginfile.php/8252/user/icon/f1

I've searched the db and cant seem to locate any instance of 8252 in my record.

What I need this for is: we use the image loaded in moodle with-in various other services so the user can be easily indentified.

any pointer or clues would be greatly appreciated

Pete

In reply to Peter Easton

Re: Databases: Need to find user picture location in the database

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The number is the contextid for the user.

$context = context_user::instance($userid);
$contextid = $context->id;

(If you need to get it without going through Moodle code, you can loook in the mdl_context table, for an entry with: contextlevel = 30, instanceid = $userid and return the id value)

Average of ratings: Useful (1)
In reply to Davo Smith

Re: Databases: Need to find user picture location in the database

by Peter Easton -

perfect,

i created a view that merged the tables and spits of the contextid based on the idnumber.

thanks

Pete