summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-12-20 21:59:17 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-12-20 21:59:17 +0000
commit374a4527387aafe4060fe2a7121a8e6429aa56da (patch)
tree6dc177861c407bd7a5abb544da707fcf14c83a23 /modules
parent12957adbf82d5c306366d4154b78dd063bbbac5c (diff)
downloadbrdo-374a4527387aafe4060fe2a7121a8e6429aa56da.tar.gz
brdo-374a4527387aafe4060fe2a7121a8e6429aa56da.tar.bz2
#172993 by drewish, Lynn: remove old user picture even when the newly uploaded one uses a different format
Diffstat (limited to 'modules')
-rw-r--r--modules/user/user.module5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/user/user.module b/modules/user/user.module
index 10f3978ce..215a7372f 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.