Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions classes/toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ public static function get_default_image_container_ratio() {
*/
public function get_displayed_image_uri($coursesectionimage, $coursecontextid, $sectionid, $displayediswebp) {
$filename = $coursesectionimage->image;
$filetype = strtolower(pathinfo($filename ?? '', PATHINFO_EXTENSION));

if ($displayediswebp) {
$filetype = strtolower(pathinfo($filename ?? '', PATHINFO_EXTENSION));
if (!empty($filetype)) {
if ($filetype != 'webp') {
$filename .= '.webp';
$filetype = 'webp';
}
} else {
$filename .= '.webp';
Expand All @@ -118,7 +119,7 @@ public function get_displayed_image_uri($coursesectionimage, $coursecontextid, $
$image = \moodle_url::make_pluginfile_url(
$coursecontextid,
'format_grid',
'displayedsectionimage',
$filetype === 'gif' ? 'sectionimage' : 'displayedsectionimage',
$sectionid,
'/' . $coursesectionimage->displayedimagestate . '/',
$filename
Expand Down
4 changes: 2 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ function format_grid_pluginfile($course, $birecordorcm, $context, $filearea, $ar
// Check if user has capability to access course.
require_course_login($course);

if ($filearea !== 'displayedsectionimage') {
if ($filearea !== 'sectionimage' && $filearea !== 'displayedsectionimage') {
send_file_not_found();
}

Expand All @@ -1047,7 +1047,7 @@ function format_grid_pluginfile($course, $birecordorcm, $context, $filearea, $ar
$filename = $args[2];
$sectionid = $args[0];

$file = $fs->get_file($context->id, 'format_grid', 'displayedsectionimage', $sectionid, '/', $filename);
$file = $fs->get_file($context->id, 'format_grid', $filearea, $sectionid, '/', $filename);
if (!$file || $file->is_directory()) {
send_file_not_found();
}
Expand Down