From 374a4527387aafe4060fe2a7121a8e6429aa56da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Thu, 20 Dec 2007 21:59:17 +0000 Subject: [PATCH] #172993 by drewish, Lynn: remove old user picture even when the newly uploaded one uses a different format --- modules/user/user.module | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/user/user.module b/modules/user/user.module index 10f3978ce17..215a7372f2a 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -391,6 +391,11 @@ function user_validate_picture(&$form, &$form_state) { 'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024), ); if ($file = file_save_upload('picture_upload', $validators)) { + // Remove the old picture. + if (isset($form_state['values']['_account']->picture) && file_exists($form_state['values']['_account']->picture)) { + file_delete($form_state['values']['_account']->picture); + } + // The image was saved using file_save_upload() and was added to the // files table as a temporary file. We'll make a copy and let the garbage // collector delete the original upload.