Steps to reproduce.

1. Make sure the Drupal overlay module is enabled. Or just use the default install profile on a clean install.
2. Create a node with an image frield crop field.
3. Select edit on the node.
4. Select remove on the image field crop widget.
5. Instead of submitting or canceling the form with the buttons at the bottom select the "x" at the top right of the modal overlay.
6. Select edit again on the same node.

After completing these steps the primary image has been deleted and the crop widget only displays the thumbnail. The file should only be deleted on node submit instead of immediately.

Comments

Anonymous’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Priority: Normal » Major

Yep, the original file gets deleted once it is removed and if the user navigates away without adding a new image they are stuck with two cropped images when they come back to edit page. Guess this is major.

jnavane’s picture

below function is processing when we are removing the image at instance

function imagefield_crop_widget_delete($form, &$form_state) {
  $parents = array_slice($form_state['triggering_element']['#array_parents'], 0, -1);
  $element = drupal_array_get_nested_value($form_state['values'], $parents);
  $orig = _imagefield_crop_file_to_crop($element['fid']);
 /*if ($orig->fid != $element['fid']) {
   file_usage_delete($orig, 'imagefield_crop');
   file_delete($orig);
   $crop_info = variable_get('imagefield_crop_info', array());
   unset($crop_info[$element['fid']]);
   variable_set('imagefield_crop_info', $crop_info);
  }*/
}

Here I have disabled the if statement ($orig->fid != $element['fid']). So I didn't lose my original image. Is this a right way to fix the issue? I hope this will help.

zschopper’s picture

Issue summary: View changes

It's simplier to remove/comment out imagefield_crop_widget_delete callback from end of imagefield_crop_widget_process() function:

<?php
function imagefield_crop_widget_process($element, &$form_state, $form) {
  ...
//  array_unshift($element['remove_button']['#submit'], 'imagefield_crop_widget_delete');
}
?>

But with this solution all original files remain on server (form submit deletes only cropped image).