Hi,
I am using standard_intro_elements() in a custom module form which works well but I have difficulty displaying the images uploaded with the Editor (Atto). I try to stick to Moodle convention as much as I can. My module is called mod_ainst. The is displayed in the Atto editor in edit mode so it seems to be uploaded.
here is my setup:
mod_form.php
class mod_ainst_mod_form extends moodleform_mod {
public function definition() {
...
$this->standard_intro_elements(get_string('custom name', 'module'));
...
$this->add_action_buttons();
}
}
/classes/output/view_page.php
class view_page implements renderable, templatable {
...
public function export_for_template(renderer_base $output) {
....
// without this function I get @@pluginfile@@/image.jpg in my template
$data->instruction->intro = file_rewrite_pluginfile_urls(
$data->instruction->intro, 'pluginfile.php', $context->id,
'mod_ainst', 'intro', 0
);
....
return $data;
}
}
view.php
...
$output = $PAGE->get_renderer('mod_ainst');
echo $output->header();
$renderable = new \mod_ainst\output\view_page($cm);
echo $output->render($renderable);
echo $output->footer();
lib.php
// I don't know why this function is not called.
function ainst_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
exit('ainst_pluginfile');
}
When I look at the URL generated by file_rewrite_pluginfile_urls(). It seems like a perfectly good URL and all the value in it match the database values in mdl_file table.
mdl_files.contextid = 13532
mdl_files.component = 'mod_ainst'
mdl_files.filearea = 'intro';
mdl_files.itemid = 0;
mdl_files.filename = 'search_execp.png'
When loaded directly into the browser I get:
Error code: filenotfound
Stack trace:
line 494 of /lib/setuplib.php: moodle_exception thrown
line 2074 of /lib/filelib.php: call to print_error()
line 4933 of /lib/filelib.php: call to send_file_not_found()
line 44 of /pluginfile.php: call to file_pluginfile()
Moodle 3.8.3+ (Build: 20200626)
Thank you in advance for your help