I am creating a tenant feature, one of the features is that when creating a new tenant, the admin uploads an image for their logo. The logo is then displayed to all users that are assigned to that tenant. I am having trouble with retreiving this stored image, and displaying it in an <img> tag.
I have set up a custom form, which has a filemanager element (not sure if I should be using filepicker). I've managed to get it to store the image and display it in the draft area when editing the record.
I used this to store the image:
file_save_draft_area_files($data->logo, 1, 'tenant', 'attachment',
$data->id, array('subdirs' => 0, 'maxfiles' => 1));
And this to retrieve it in the filemanager when editing the record:
$draftitemid = file_get_submitted_draft_itemid('logo');
file_prepare_draft_area($draftitemid, 1, 'tenant', 'attachment', $data->id,
array('subdirs' => 0, 'maxfiles' => 1));
This seems to work fine. What I'm having trouble with now is getting the image url and using that to display the image.
I've been trying using this but it says the file does not exist.
$imageurl = moodle_url::make_pluginfile_url(1, 'tenant', 'attachment', $tenantid, '/', 'f1');
What am I doing wrong? I am using moodle 2.8.1