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

This commit is contained in:
Andrew Davis
2011-11-28 12:58:44 +08:00
parent 79b0fece1f
commit 6b2f218473
2 changed files with 7 additions and 0 deletions
+6
View File
@@ -987,6 +987,12 @@ class file_storage {
* @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();
}
+1
View File
@@ -266,6 +266,7 @@ class data_field_picture extends data_field_base {
$fs->convert_image($file_record, $file, $this->field->param4, $this->field->param5, true);
return true;
} catch (Exception $e) {
debugging($e->getMessage());
return false;
}
}