Skip to content

Commit

Permalink
Merge branch 'MDL-70968-311' of git://github.com/marinaglancy/moodle …
Browse files Browse the repository at this point in the history
…into MOODLE_311_STABLE
  • Loading branch information
stronk7 committed Mar 17, 2021
2 parents 6f2b581 + ac06e60 commit d42107e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/gdlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ function process_new_icon($context, $component, $filearea, $itemid, $originalfil

$icon = array('contextid'=>$context->id, 'component'=>$component, 'filearea'=>$filearea, 'itemid'=>$itemid, 'filepath'=>'/');

if ($imagefnc === 'imagejpeg') {
// Function imagejpeg() accepts less arguments than imagepng() but we need to make $imagefnc accept the same
// number of arguments, otherwise PHP8 throws an error.
$imagefnc = function($image, $filename, $quality, $unused) {
return imagejpeg($image, $filename, $quality);
};
}

ob_start();
if (!$imagefnc($im1, NULL, $quality, $filters)) {
// keep old icons
Expand Down Expand Up @@ -384,6 +392,14 @@ function resize_image_from_image($original, $imageinfo, $width, $height, $forcec

imagecopybicubic($newimage, $original, $dstx, $dsty, 0, 0, $targetwidth, $targetheight, $originalwidth, $originalheight);

if ($imagefnc === 'imagejpeg') {
// Function imagejpeg() accepts less arguments than imagepng() but we need to make $imagefnc accept the same
// number of arguments, otherwise PHP8 throws an error.
$imagefnc = function($image, $filename, $quality, $unused) {
return imagejpeg($image, $filename, $quality);
};
}

// Capture the image as a string object, rather than straight to file.
ob_start();
if (!$imagefnc($newimage, null, $quality, $filters)) {
Expand Down

0 comments on commit d42107e

Please sign in to comment.