I am writing a local plugin which will get the course summary from get_course() and place it on the page.
mymoodle.com/local/my_plugin/?courseid=3 produces:
<img src="http://mymoodle.com/pluginfile.php/1/course/summary/0/half_coffee.jpg" alt="Half a cup of coffee" class="img-responsive atto_image_button_text-bottom" width="237" height="122">
which does not produce an image. The files table has:
I'm unsure how and why the code doesn't work if I either get the contextid from the page (returns a 1) or use the context ID in the files table above. I'm also unsure of the item id and how I should be obtaining that.
My code is:
function local_pluginname_get_course_blurb($courseid) {
$course = get_course($courseid);
//parameters ($text, $itemid should be obtained dynamically by sql - this is just an example)
$text = $course->summary;
$file = "pluginfile.php";
$component = "course";
$filearea = "summary";
$contextid = 1;
$itemid = 0;
$course_blurb = file_rewrite_pluginfile_urls($text, $file, $contextid, $component, $filearea, $itemid);
return $course_blurb;
}
Cheers
Dave