Default Avatar by Username

Started by gecitli, November 02, 2019, 04:39:39 AM

Previous topic - Next topic

gecitli

Hi how do I adapt these codes to smf 2.1

./Sources/Load.php

Find

// Are we also loading the members custom fields into context?


Add Before
// Default Avatar by Username.
if($memberContext[$user]['avatar']['image'] == '')
{
preg_match('/^[a-z]/i', $memberContext[$user]['name'], $damatch);
$damatch = empty($damatch) ? 'none' : strtolower($damatch[0][0]);
$memberContext[$user]['avatar'] = array(
'name' => $settings['images_url'] . '/avatar/' . $damatch . '.png',
'image' => '<img class="avatar" src="' . $settings['images_url'] . '/avatar/' . $damatch . '.png" alt="" />',
'href' => $settings['images_url'] . '/avatar/' . $damatch . '.png',
'url' => $settings['images_url'] . '/avatar/' . $damatch . '.png',
);
}


./Sources/Subs.php

Find
// Figure out how long they've been logged in.

Add Before

// Default Avatar by Username.
if(empty($context['user']['avatar']['image']))
{
preg_match('/^[a-z]/i', $context['user']['name'], $damatch);
$damatch = empty($damatch) ? 'none' : strtolower($damatch[0][0]);
$context['user']['avatar'] = array(
'name' => $settings['images_url'] . '/avatar/' . $damatch . '.png',
'image' => '<img class="avatar" src="' . $settings['images_url'] . '/avatar/' . $damatch . '.png" alt="" />',
'href' => $settings['images_url'] . '/avatar/' . $damatch . '.png',
'url' => $settings['images_url'] . '/avatar/' . $damatch . '.png',
);
}


related topic https://custom.simplemachines.org/mods/index.php?mod=4064
http://www.webtiryaki.com
webmaster forumu
Free & Premium Responsive Themes for SMF.

gecitli

http://www.webtiryaki.com
webmaster forumu
Free & Premium Responsive Themes for SMF.

Advertisement: