Skip to content

Commit

Permalink
Fix bug where vimeo plugin would not fix output of mod_url activity
Browse files Browse the repository at this point in the history
  • Loading branch information
kristian-94 committed Mar 31, 2023
1 parent 5898c3e commit b1c8eb5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions media/player/vimeo/classes/plugin.php
Expand Up @@ -34,7 +34,7 @@
*/
class media_vimeo_plugin extends core_media_player_external {
protected function embed_external(moodle_url $url, $name, $width, $height, $options) {
$videoid = $this->get_video_id();
$videourl = $this->get_video_player_url();
$info = s($name);

// Note: resizing via url is not supported, user can click the fullscreen
Expand All @@ -44,7 +44,7 @@ protected function embed_external(moodle_url $url, $name, $width, $height, $opti

$output = <<<OET
<span class="mediaplugin mediaplugin_vimeo">
<iframe title="$info" src="https://player.vimeo.com/video/$videoid"
<iframe title="$info" src="$videourl"
width="$width" height="$height" frameborder="0"
webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</span>
Expand All @@ -53,6 +53,10 @@ protected function embed_external(moodle_url $url, $name, $width, $height, $opti
return $output;
}

public function get_video_player_url(): string {
return "https://player.vimeo.com/video/{$this->get_video_id()}";
}

/**
* Get Vimeo video ID.
* @return string
Expand Down
9 changes: 9 additions & 0 deletions mod/url/lib.php
Expand Up @@ -280,6 +280,15 @@ function url_export_contents($cm, $baseurl) {
return [];
}

$plugins = \core\plugininfo\media::get_enabled_plugins();
if (array_key_exists('vimeo', $plugins)) {
$media_vimeo_plugin = new media_vimeo_plugin();
$moodleurl = new moodle_url($fullurl);
if ($media_vimeo_plugin->list_supported_urls([$moodleurl])) {
$fullurl = $media_vimeo_plugin->get_video_player_url();
}
}

$url = array();
$url['type'] = 'url';
$url['filename'] = clean_param(format_string($urlrecord->name), PARAM_FILE);
Expand Down

0 comments on commit b1c8eb5

Please sign in to comment.