--- uc_option_image.module +++ uc_option_image.module @@ -152,6 +152,11 @@ '#size' => 8, '#default_value' => $file->filename, ); + if ($file->filename != 'option_image_0_0_0') { + $form['attributes'][$aid]['options'][$oid]['remove'] = array( + '#type' => 'checkbox', + ); + } } } } @@ -527,9 +532,14 @@ foreach($aids AS $aid){ if ($oids = element_children($form_state['values']['attributes'][$aid]['options'])){ foreach($oids AS $oid){ - uc_option_image_save($form_state['values']['id'], $aid, $oid); - } - } + if ($form_state['values']['attributes'][$aid]['options'][$oid]['remove']) { + uc_option_image_delete($form_state['values']['id'], $aid, $oid); + } + else { + uc_option_image_save($form_state['values']['id'], $aid, $oid); + } + } + } } } } @@ -665,7 +675,7 @@ * Add our image fields to the table. */ function phptemplate_uc_object_options_form($form) { - $header = array(t('Attribute'), t('Options'), t('Default'), t('Cost'), t('Price'), t('Weight'), t('Order'), t('Image'), t('Preview')); + $header = array(t('Attribute'), t('Options'), t('Default'), t('Cost'), t('Price'), t('Weight'), t('Order'), t('Image'), t('Preview'), t('Remove')); foreach (element_children($form['attributes']) as $key) { $row = array(); @@ -683,6 +693,7 @@ // MOD: added the image field and preview $row[] = drupal_render($form['attributes'][$key]['options'][$oid][uc_option_image_id(arg(1), $key, $oid)]); $row[] = drupal_render($form['attributes'][$key]['options'][$oid]['option_image_preview']); + $row[] = drupal_render($form['attributes'][$key]['options'][$oid]['remove']); if (!$first) { // MOD: changed from -7 to -9 to accomidate the new columns