Merge pull request #2 from harshvardhanmalpani/master

better blank avatars
pull/44/head
Harshvardhan Malpani 2019-06-03 11:04:12 +05:30 committed by GitHub
commit 49e8116308
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -555,6 +555,13 @@ class User {
);
}
}
else
{
$user['avatar'] = array(
'filename' => getLatestImage($user['id'])[0],
'url' => getLatestImage($user['id'])[1]
);
}
unset($user['avatar_filename']);
if($user['background_filename']) {

View File

@ -463,6 +463,17 @@ function get_users_image_url($filename) {
return get_content_url('images/users/'.$filename);
}
function getLatestImage($user)
{
$db = DB::getInstance();
$db->query('select image_name,image_extension,image_date FROM '.DB::getTable('images').' where `image_user_id`='.$user.' order by image_date desc limit 1');
$user_images = $db->fetchAll();
$st=strtotime($user_images[0]['image_date']);
$dloc='/'.getSetting('upload_image_path').date("/Y/m/d/",$st);
return array($user_images[0]['image_name'],$dloc.$user_images[0]['image_name'].'.'.$user_images[0]['image_extension']);
}
/**
* Some G\ overrides
*/