Advertisement:

Author Topic: Default Avatar by Username  (Read 324 times)

Offline gecitli

  • Jr. Member
  • **
  • Posts: 294
    • webmaster forumu
Default Avatar by Username
« on: November 02, 2019, 04:39:39 AM »
Hi how do I adapt these codes to smf 2.1

./Sources/Load.php

Find
Code: [Select]
// Are we also loading the members custom fields into context?
Add Before
Code: [Select]
// 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
Code: [Select]
// Figure out how long they've been logged in.
Add Before

Code: [Select]
// 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.

Offline gecitli

  • Jr. Member
  • **
  • Posts: 294
    • webmaster forumu
Re: Default Avatar by Username
« Reply #1 on: December 02, 2019, 10:40:49 AM »
Hi I'm waiting for help on this.
http://www.webtiryaki.com

webmaster forumu

Free & Premium Responsive Themes for SMF.