1. czarrna
  2. General
  3. Tuesday, February 02 2016, 03:44 PM
Hi,

I am testing uploading avatars for users and it works perfect including crop and rotate. Thanks so much for this excellent improvement! :D

I've noticed an issue when a user wants to change the image - he/she can but the old profile image is not removed even if "delete image" is thicked.

So, considering hundreds of users that would likely want to change their images from time to time - it will be a mess and it will take some space on the server.

Any ideas how to deal with this??


Many thanks
Accepted Answer
admin Accepted Answer
Admin
Thx for report it, we will solve in next release.

Add this code in file /administrator/components/com_jsn/helpers/fields/image.php after line 173:
foreach (glob($upload_dir.$alias.$data['id'].'*') as $deletefile)
{
unlink($deletefile);
}


so become something like this:
........
$md5=md5(time().rand());
$filename=$alias.$data['id'].'_'.$md5.'.png';
$filename_mini=$alias.$data['id'].'mini_'.$md5.'.png';
$path = JPATH_SITE.'/images/_tmp/';
$file = $session->get('_tmp_img_'.$alias,'');
if(file_exists($path . str_replace('.','-big.',$file)) && file_exists($path . str_replace('.','-big.',$file))){
////// START NEW CODE
foreach (glob($upload_dir.$alias.$data['id'].'*') as $deletefile)
{
unlink($deletefile);
}
////// END NEW CODE
rename($path . str_replace('.','-big.',$file),$upload_dir.$filename);
rename($path . str_replace('.','-mini.',$file),$upload_dir.$filename_mini);
unlink($path . $file);
$storeData[$alias]=$upload_path.$filename;
}
......


This remove also oldest image ;)
  1. more than a month ago
  2. General
  3. # Permalink
czarrna Accepted Answer
Content Protected
  1. more than a month ago
  2. General
  3. # 1
admin Accepted Answer
Admin
hi,
strange this code was tested. anyway, on localhost we can't check your problem, so try to see your PHP error log.
  1. more than a month ago
  2. General
  3. # 2
czarrna Accepted Answer
Content Protected
  1. more than a month ago
  2. General
  3. # 3
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.