@@ -346,7 +346,7 @@
   // Validate the number of attached images. Filter out the 'None' with array_filter.
   if ($maximum_images = variable_get('image_attach_maximum_' . $form['#node']->type, 0)) {
     $uploading_new_image = ($form_state['clicked_button']['#value'] == t('Attach'));
-    $num_images = count(array_filter($form_state['values']['iids']));
+    $num_images = isset($form_state['values']['iids']) ? count(array_filter($form_state['values']['iids'])) : 0;
 
     $node_type_label = node_get_types('name', $form['#node']->type);
     if ($num_images >= $maximum_images && $uploading_new_image) {
@@ -399,7 +399,9 @@
 function image_attach_node_form_submit(&$form, &$form_state) {
   // Clear the 0 key in the iids array that arises from selecting the 'None'
   // option. We do this here so image_attach_nodeapi() gets clean data.
-  unset($form_state['values']['iids'][0]);
+  if (isset($form_state['values']['iids'][0])) {
+    unset($form_state['values']['iids'][0]);
+  }
 }
 
 /**
