-
Improvement
-
Resolution: Duplicate
-
Minor
-
None
-
2.4.3, 2.4.4, 2.4.5, 2.4.6
-
MOODLE_24_STABLE
If a image (jpeg,gif,png) is inserted into the RTE in a forum post, the image is not visible in the generated mail.
Solution:
/lib/moodlelib:
function email_to_user:
+add (row ~5389):
<code>
if($messagehtml) { //HTML Message
$messagehtml=rawurldecode($messagehtml);
//CHG sbrandstaetter: Push image directly in mails
$pattern = "/src=\"([^(\"|\')]
(png|jpg|jpeg|pjpeg|gif))\"/i";
preg_match_all($pattern, $messagehtml, $images);
foreach($images[1] as $image){
$dataString = explode('pluginfile.php/',$image);
$data=explode('/',$dataString[1]);
$fs = get_file_storage();
// Prepare file record object
$fileinfo = array(
'component' => $data[1], // usually = table name
'filearea' => $data[2], // usually = table name
'itemid' => $data[3], // usually = ID of row in table
'contextid' => $data[0], // ID of context
'filepath' => '/', // any path beginning and ending in /
'filename' => $data[4]); // any filename
// Get file
$file = $fs->get_file($fileinfo['contextid'], $fileinfo['component'], $fileinfo['filearea'],
$fileinfo['itemid'], $fileinfo['filepath'], $fileinfo['filename']);
$im=false;
// Read contents
if ($file) {
$im = $file->get_content();
$imInfo = $file->get_imageinfo();
if($im)
}
}
}
</code>
I know it is not the "beatiful way", but it works fine for me.
kind regards
Simon Brandstätter