Skip to content
Permalink
Browse files

[add] Добавлен метод отдающий url аватара и аватар по умолчанию

  • Loading branch information...
KpuTuK committed Oct 6, 2019
1 parent e0b3aa2 commit b5c9a021724d69f8f9e1d5ec8054007ff7b65900
Showing with 25 additions and 3 deletions.
  1. +4 −3 files/avatars/.gitignore
  2. BIN files/avatars/no_ava.jpg
  3. +21 −0 modules/user/helpers/user.php
@@ -1,3 +1,4 @@
!empty_32.png
!guest_32.png
*
!empty_32.png
!guest_32.png
*
!/no_ava.jpg
Binary file not shown.
@@ -128,6 +128,27 @@ public static function online_status($last_visit)
}
}
public static function getAvatarUrl($user_id)
{
if (file_exists(ROOT . 'files/avatars/' . $user_id . '_100' . '.png'))
return URL . 'files/avatars/' . $user_id . '_100.png';
elseif (file_exists(ROOT . 'files/avatars/' . $user_id . '_150' . '.png'))
return URL . 'files/avatars/' . $user_id . '_150.png';
elseif (file_exists(ROOT . 'files/avatars/' . $user_id . '_100' . '.gif'))
return URL . 'files/avatars/' . $user_id . '_100.gif';
elseif (file_exists(ROOT . 'files/avatars/' . $user_id . '_150' . '.gif'))
return URL . 'files/avatars/' . $user_id . '_150.gif';
elseif (file_exists(ROOT . 'files/avatars/' . $user_id . '_100' . '.jpg'))
return URL . 'files/avatars/' . $user_id . '_100.jpg';
elseif (file_exists(ROOT . 'files/avatars/' . $user_id . '_150' . '.jpg'))
return URL . 'files/avatars/' . $user_id . '_150.jpg';
elseif (file_exists(ROOT . 'files/avatars/' . $user_id . '_100' . '.jpeg'))
return URL . 'files/avatars/' . $user_id . '_100.jpeg';
elseif (file_exists(ROOT . 'files/avatars/' . $user_id . '_150' . '.jpeg'))
return URL . 'files/avatars/' . $user_id . '_150.jpeg';
else return URL . 'files/avatars/no_ava.jpg';
}
}
?>

0 comments on commit b5c9a02

Please sign in to comment.
You can’t perform that action at this time.