Hello devs,
Previously I have already asked about displaying an uploaded through a filepicker image in the browser in this post https://moodle.org/mod/forum/discuss.php?d=433320. The Davo's answer, local plugin filemanager and example of logocompact helped me to succeed in displaying an uploaded image in the browser also to not authorized users.
My current problem is to insert an uploaded image into an email so, that a recipient can see it. Honestly speaking, I thought, that I met all conditions for that, but apparently I am missing something and for some Moodle security reasons an image is still not being showed.
For testing purpose I inserted a logocompact image into an email. Attached you can find a screenshot showing a corresponding email with inserted image sent by facetoface plugin.
My code is as follows:
--- facetoface/lib.php:
function facetoface_email_substitutions($msg, $facetofacename, $reminderperiod, $user, $data, $sessionid) {
global $CFG, $DB;
if (empty($msg)) {
return '';
}
...
## In configs of a facetoface instance the text of emails contains a signature placeholder ## that is replaced by the signature itself
// in lang file $string['placeholder:signature'] = '[signature]'
$msg = str_replace(get_string('placeholder:signature', 'facetoface'), build_signature_for_emails(), $msg);
return $msg;
} function build_signature_for_emails() { $emailsignature = get_config('mod_facetoface', 'facetoface_email_signature'); $emailsignatureimg = get_signature_img(); $emailsignature = str_replace( get_string('placeholder:signatureimg', 'facetoface'), $emailsignatureimg, '<h1>Signature</h1><br>[img]' ); return $emailsignature; }
function get_signature_img() { global $OUTPUT; return html_writer::empty_tag( 'img', [ 'src' => $OUTPUT->get_compact_logo_url(null, 150), 'alt' => 'test', 'class' => 'img-fluid' ] ); }
Thank you very much for your help in advance.