Merge branch 'MDL-27432_gd_error' of git://github.com/andyjdavis/moodle
authorAparup Banerjee <aparup@moodle.com>
Thu, 8 Dec 2011 05:56:51 +0000 (13:56 +0800)
committerAparup Banerjee <aparup@moodle.com>
Thu, 8 Dec 2011 05:56:51 +0000 (13:56 +0800)
lib/filestorage/file_storage.php
mod/data/field/picture/field.class.php

index 9b22b01..d61e10f 100644 (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();
         }
index 3086c84..269e916 100644 (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;
         }
     }