ui-avatars
ui-avatars copied to clipboard
Make it an array the "multiple usernames joined" exclusions on a per use case
It happens some fancy user likes to join multiple usernames with an hyphenation or the likes, I started making an array of exclusions which is managed as per admin's choice in the phpBB's ACP (Administration Control Panel)
This way.. you know ;)
/* for user "John Doe" or "John_Doe" use 'John+Doe' etc */ $pia_rep_ary = [' ', '_']; $name = str_replace($pia_rep_ary, '+', $this->user->data['username']);
Wouldnt this work by replacing the variables locally instead? Like:
// User Model/Class
...
function formattedUsername() {
$username = $this->data['username'];
$username = str_replace('_', '+', $username);
$username = str_replace(' ', '+', $username);
return $username;
}
// Usage
<img src="<?php echo 'https://ui-avatars.com/api/?name=' . $this->user->formattedUsername(); ?>" />
I just feel that this may be a little out of scope for the core library, to handle, but I'm not sure 😄
Yup, that's fine. :) I will re-think about the purpose though.
Well, easily managed on the present code so no probs. Just thinking about an username like: AlexanderTheGreat .. how would it be the more elegant way to deal with it and have a result like this: ATG ?¿ Is it something the API should take into consideration IYO?
Hi, any news on this? Are you still working on the API mate?