Good day to you,
i extended a face-to-face plugin with a filepicker in global settings. I am working with moodle 3.9.
My goal is to upload a logo picture and to insert it in to a user notification emails as a part of a company's signature. For testing purposes I display an uploaded image in the browser first, on the test.php page. Unfortunately, browser tells me, that it can not find the image.
For a comparison of the URLs, I output the logocompact using method of the core renderer_base class.
My code is as follows:
--- settings.php:
$setting = new admin_setting_configstoredfile(
'facetoface_email_signature_img',
get_string('setting:emailsignatureimg', 'facetoface'),
get_string('setting:emailsignatureimg_caption', 'facetoface'),
'signature_image',
0,
['maxfiles' => 1, 'accepted_types' => ['.jpg', '.png', '.svg']]
);
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
--- test.php:
require_once(dirname(__FILE__, 3) . '/config.php'); global $OUTPUT;
$fs = get_file_storage();
if ($files = $fs->get_area_files($systemcontext->id, 'core', 'signature_image')) {The output, that I get in the browser, is shown by two screenshots attached below. Additionally I attached a screenshot showing the corresponding mdl_files records.
foreach ($files as $file) {
if ($file->is_directory()) continue;
$fileurl = moodle_url::make_pluginfile_url(
$file->get_contextid(),
$file->get_component(),
$file->get_filearea(),
$file->get_itemid(),
$file->get_filepath(),
$file->get_filename()
);
$img = html_writer::img($fileurl, 'test');
echo $img;
}
}
echo \html_writer::img($OUTPUT->get_compact_logo_url(null, 150), 'test');
I assume, the problem is the incorrect URL, which I build and that it could be fixed by using theme_get_revision(), which is used in get_compact_logo_url(). But for now all my attempts to manually integrate the output of theme_get_revision() into a URL were not successful.
Do you have any idea, why I can not access an image from the filepicker?
Thank you for you help in advance