function get_media_tag in Quiz 6.6
Same name and namespace in other branches
- 6.5 includes/moodle/question/format/qti2/qt_common.php \get_media_tag()
creates a media tag to use for choice media
Parameters
string $file the filename:
string $courseid the course id:
string $alt to specify the alt tag:
Return value
string either an image tag, or html for an embedded object
File
- includes/
moodle/ question/ format/ qti2/ qt_common.php, line 99
Code
function get_media_tag($file, $courseid = 0, $alt = 'media file', $width = 0, $height = 0) {
global $CFG;
// if it's a moodle library file, it will be served through file.php
if (substr(strtolower($file), 0, 7) == 'http://') {
$media = $file;
}
else {
require_once $CFG->libdir . '/filelib.php';
$media = get_file_url("{$courseid}/{$file}");
}
$ismultimedia = false;
if (!($isimage = is_image_by_extension($file))) {
$ismultimedia = is_multimedia_by_extension($file);
}
// if there is no known width and height, try to get one
if ($width == 0) {
if ($isimage || is_sizable_multimedia($file)) {
}
}
// create either an image link or a generic link.
// if the moodle multimedia filter is turned on, it'll catch multimedia content in the generic link
if (is_image_by_extension($file)) {
return "<img src=\"{$media}\" alt=\"{$alt}\" width=\"{$width}\" height=\"{$height}\" />";
}
else {
require_once "{$CFG->dirroot}/mod/quiz/format/qti/custommediafilter.php";
return custom_mediaplugin_filter('<a href="' . $media . '"></a>', $courseid, $width, $height);
}
}