Skip to content

Commit

Permalink
Merge branch 'MDL-64346-master' of git://github.com/abgreeve/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjona committed Jan 15, 2019
2 parents a27dbff + b70c364 commit ce5ca79
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions mod/resource/locallib.php
Expand Up @@ -66,9 +66,8 @@ function resource_display_embed($resource, $cm, $course, $file) {
$clicktoopen = resource_get_clicktoopen($file, $resource->revision);

$context = context_module::instance($cm->id);
$path = '/'.$context->id.'/mod_resource/content/'.$resource->revision.$file->get_filepath().$file->get_filename();
$fullurl = file_encode_url($CFG->wwwroot.'/pluginfile.php', $path, false);
$moodleurl = new moodle_url('/pluginfile.php' . $path);
$moodleurl = moodle_url::make_pluginfile_url($context->id, 'mod_resource', 'content', $resource->revision,
$file->get_filepath(), $file->get_filename());

$mimetype = $file->get_mimetype();
$title = $resource->name;
Expand All @@ -82,11 +81,11 @@ function resource_display_embed($resource, $cm, $course, $file) {
);

if (file_mimetype_in_typegroup($mimetype, 'web_image')) { // It's an image
$code = resourcelib_embed_image($fullurl, $title);
$code = resourcelib_embed_image($moodleurl->out(), $title);

} else if ($mimetype === 'application/pdf') {
// PDF document
$code = resourcelib_embed_pdf($fullurl, $title, $clicktoopen);
$code = resourcelib_embed_pdf($moodleurl->out(), $title, $clicktoopen);

} else if ($mediamanager->can_embed_url($moodleurl, $embedoptions)) {
// Media (audio/video) file.
Expand Down

0 comments on commit ce5ca79

Please sign in to comment.