Index: contributions/modules/flexinode/field_image.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flexinode/field_image.inc,v
retrieving revision 1.20
diff -u -p -r1.20 field_image.inc
--- contributions/modules/flexinode/field_image.inc	26 Apr 2006 11:43:34 -0000	1.20
+++ contributions/modules/flexinode/field_image.inc	25 Jan 2007 22:41:16 -0000
@@ -21,12 +21,24 @@ function flexinode_field_image_form($fie
       '#value' => serialize($node->$fieldname),
       );
   }
-  $form[$fieldname] = array(
+  $form[$fieldname] = array('#type' => 'fieldset',
+    '#title' => t($field->label),
+    '#weight' => $field->weight,
+    '#collapsible' => TRUE,
+    '#collapsed' => (strlen($node->$fieldname->filename) == 0),
+  );
+  $form[$fieldname][$fieldname] = array(
     '#type' => 'file',
     '#title' => t($field->label),
     '#description' =>  ($node->$fieldname ? t('"%filename" has been uploaded. If you upload another file, the current file will be replaced.', array('%filename' => $node->$fieldname->filename)) : '') .' '. t($field->description) .' '. t('The file is limited to %kbKB and a resolution of %wxh pixels (width x height).', array('%wxh' => $field->options[1], '%kb' => $field->options[4])),
     '#required' => $field->required,
-    '#weight' => $field->weight,
+    '#weight' => 0,
+    );
+  $form[$fieldname][$fieldname.'_delete'] = array('#type' => 'checkbox',
+      '#title' => t('Delete image'),
+      '#default_value' => 0,
+      '#description' => t('Image will be deleted after selecting the above checkbox and submitting this page.'),
+      '#weight' => 1,
     );
   
   return $form;
@@ -43,6 +55,13 @@ function flexinode_field_image_db_sort_c
 
 function flexinode_field_image_insert($field, $node) {
   $fieldname = 'flexinode_'. $field->field_id;
+  $fieldnamedelete = $fieldname . '_delete';
+  if ($node->$fieldnamedelete == 1) {
+    file_delete($node->$fieldname->filepath);
+    file_delete($node->$fieldname->smallpath);
+    file_delete($node->$fieldname->thumbpath);
+    return $node;
+  }
   $node->$fieldname = file_save_upload($node->$fieldname, $node->$fieldname->filename);
   $node->$fieldname->smallpath = flexinode_field_image_make_smaller($node->$fieldname->filepath, '_sm', $field->options[2]);
   $node->$fieldname->thumbpath = flexinode_field_image_make_smaller($node->$fieldname->filepath, '_th', $field->options[3]);
