Code

Ticket #2983: image_field_delete_orig_on_update.patch

File image_field_delete_orig_on_update.patch, 712 bytes (added by Tim Goh <timgoh@…>, 8 years ago)

against r4085

  • __init__.py

     
    666666 
    667667    def save_file(self, new_data, new_object, original_object, change, rel): 
    668668        FileField.save_file(self, new_data, new_object, original_object, change, rel) 
     669        upload_field_name = self.get_manipulator_field_names('')[0] 
     670        if new_data.get(upload_field_name, False) and change: 
     671            self.delete_file(original_object) # delete original file 
    669672        # If the image has height and/or width field(s) and they haven't 
    670673        # changed, set the width and/or height field(s) back to their original 
    671674        # values.