Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#220 - made a fix for .gif images not being animated #220

Open
wants to merge 1 commit into
base: MOODLE_401
Choose a base branch
from
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