Permalink
Browse files

MDL-27432 mod_data: improved handling of the absence of the GD php ex…

…tension
  • Loading branch information...
1 parent 79b0fec commit 6b2f218473ae72c7ca9ecd8a9a797734ff7b5052 @andyjdavis andyjdavis committed Nov 28, 2011
Showing with 7 additions and 0 deletions.
  1. +6 −0 lib/filestorage/file_storage.php
  2. +1 −0 mod/data/field/picture/field.class.php
@@ -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();
}
@@ -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;
}
}

0 comments on commit 6b2f218

Please sign in to comment.