Skip to content

Commit

Permalink
MDL-27432 mod_data: improved handling of the absence of the GD php ex…
Browse files Browse the repository at this point in the history
…tension
  • Loading branch information
andyjdavis committed Dec 7, 2011
1 parent 01f7f6f commit aed70c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/filestorage/file_storage.php
Expand Up @@ -987,6 +987,12 @@ public function create_file_from_string($file_record, $content) {
* @return stored_file instance
*/
public function convert_image($file_record, $fid, $newwidth = NULL, $newheight = NULL, $keepaspectratio = true, $quality = NULL) {
if (!function_exists('imagecreatefromstring')) {
//Most likely the GD php extension isn't installed
//image conversion cannot succeed
throw new file_exception('storedfileproblem', 'imagecreatefromstring() doesnt exist. The PHP extension "GD" must be installed for image conversion.');
}

if ($fid instanceof stored_file) {
$fid = $fid->get_id();
}
Expand Down
1 change: 1 addition & 0 deletions mod/data/field/picture/field.class.php
Expand Up @@ -266,6 +266,7 @@ function update_thumbnail($content, $file) {
$fs->convert_image($file_record, $file, $this->field->param4, $this->field->param5, true);
return true;
} catch (Exception $e) {
debugging($e->getMessage());
return false;
}
}
Expand Down

0 comments on commit aed70c6

Please sign in to comment.