diff --git a/epsacrop.module b/epsacrop.module index 5d901e4..569d30d 100644 --- a/epsacrop.module +++ b/epsacrop.module @@ -967,7 +967,11 @@ function _epsacrop_add_file($fid, $coords) { function _epsacrop_save_coords($fid, $coords) { // Check fid is for a valid file. if ($file = file_load($fid)) { - + $info = image_get_info($file->uri); + // Not an image. + if (!$info) { + return FALSE; + } $coords_data = drupal_json_decode($coords); // We don't know the field so assume there is only one item in the array. @@ -978,8 +982,8 @@ function _epsacrop_save_coords($fid, $coords) { if (!empty($field_coords) && ( $field_coords['x'] < 0 || $field_coords['y'] < 0 - || $field_coords['x2'] > $file->width - || $field_coords['y2'] > $file->height + || $field_coords['x2'] > $info['width'] + || $field_coords['y2'] > $info['height'] )) { return FALSE; }