Advertisement:

Author Topic: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)  (Read 58168 times)

Offline N3RVE

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,907
  • Gender: Male
    • N3RVE.COM
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #20 on: September 30, 2009, 02:02:41 AM »
Perhaps, you should try the mod instead?

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote
“Somewhere, something incredible is waiting to be known.” - Carl Sagan

Offline C4G-TK

  • Sr. Member
  • ****
  • Posts: 961
  • SHOW others respect & you GET respect in return.
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #21 on: October 05, 2009, 11:32:39 PM »
The .png should go into: Themes/"your theme"/images/   and not just Themes/"your theme" as in the first post.  At least, that's where I placed it in order for it to appear correctly.
-img removed-

Offline Nier

  • Semi-Newbie
  • *
  • Posts: 44
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #22 on: February 08, 2010, 08:24:51 AM »
I did exacly what was said in first post: The file load, searched and replaced it. Saved it. Upload a default_avatar.png to my theme map. Nothing happend if i dont select a avatar..

Offline curlin

  • Jr. Member
  • **
  • Posts: 106
    • Thoroughbred Junkie
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #23 on: February 08, 2010, 02:27:20 PM »
     Hello

  This works in the posts but it is not showing in my "newest member" simple portal block. Could you tell me what to add below? Thanks!.

Code: [Select]
global $context, $memberContext, $modSettings, $color_profile;

   $latest_member_id = $context['common_stats']['latest_member']['id'];
   loadMemberData($latest_member_id);
   loadMemberContext($latest_member_id);

   echo '
   <div style="text-align: center;">';

   if (!empty($memberContext[$latest_member_id]['avatar']['href']))
      echo '
      <img src="'.$memberContext[$latest_member_id]['avatar']['href'].'" alt="" width="60" /><br />';

   echo '
      ', $memberContext[$latest_member_id]['link'], '
   </div>';
Hoss Talk At Thoroughbred Junkie

Offline Veliki Brat

  • Jr. Member
  • **
  • Posts: 259
  • Gender: Male
    • Sve za dom
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #24 on: February 24, 2010, 04:03:02 PM »
Hi

In my case only admin see default_avatar no one else? How come?
Follow us on Twitter - Join us on Facebook - Visit our Website - Visit Forum

Web Designer & SEO Expert - WPZoom & IntenseDebate team member

SZD:M - Our latest work

Offline flapjack

  • SMF Hero
  • ******
  • Posts: 2,615
  • Gender: Male
  • I pity the fools!
I just came up with an idea: use default_avatar.png as a background for where avatar is being displayed. one small css change. however it's not 100% foolproof, when user's avatar will not be standard size, it will not look pretty

Offline sona67

  • Semi-Newbie
  • *
  • Posts: 13
Hi

In my case only admin see default_avatar no one else? How come?

same problem. This edit doesn't work. I'm using 1.1.13

Offline pearpandas

  • Semi-Newbie
  • *
  • Posts: 26
    • Cutest Quotes
This is awesome!  I'm gonna use it in my website right now!

Offline Xarcell

  • SMF Hero
  • ******
  • Posts: 1,684
  • Gender: Male
  • SMF-DP Supporter
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #28 on: December 10, 2012, 05:48:43 PM »
How come this doesn't work in the index.template.php, it works everywhere else?

Offline Antechinus

  • SMF Friend
  • SMF Master
  • *
  • Posts: 25,463
  • Master of BBC Abuse
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #29 on: December 11, 2012, 02:05:51 PM »
Not sure. It should. Have you got any weird code there?

Offline Xarcell

  • SMF Hero
  • ******
  • Posts: 1,684
  • Gender: Male
  • SMF-DP Supporter
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #30 on: December 14, 2012, 05:52:41 PM »
I think it's because member is not defined for some reason. I will attempt to debug...

Offline Xarcell

  • SMF Hero
  • ******
  • Posts: 1,684
  • Gender: Male
  • SMF-DP Supporter
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #31 on: January 01, 2013, 07:17:48 PM »
I have attempted to debug, but the default avatar just doesn't load in the header of the index.template.php file. Error log says:
Quote
Undefined index: image
in whatever template file is being viewed

Using:
Code: [Select]
', $context['user']['avatar']['image'], '

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,951
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #32 on: January 01, 2013, 07:19:37 PM »
Probably because it's not declared there, and that you need to modify the separate loading of the avatar for the current user, IIRC that's in Load.php instead.

Offline drewactual

  • Sr. Member
  • ****
  • Posts: 881
    • College Football Fan Site CFB51
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #33 on: February 07, 2019, 09:45:35 AM »
this is a nice little trick to use!!!!

however, and I don't know if it's something that has changed in the decade since it was first posted, this needs to be altered from:
Code: [Select]
if (empty($memberContext[$user]['avatar']['image']))
$memberContext[$user]['avatar']['image'] = '<img src="' . $settings['images_url'] . '/default_avatar.png" alt="Default Avatar" title="Default Avatar" width="' . $avatar_width . '" height="' . $avatar_height . '" />';


to:
Code: [Select]
if (empty($memberContext[$user]['avatar']['image']))
$memberContext[$user]['avatar']['image'] = '<img src="' . $settings['images_url'] . '/default_avatar.png" alt="Default Avatar" title="Default Avatar" ' . $avatar_width . ' ' . $avatar_height . ' />';

/

as the admin section settings already appends the
Code: [Select]
width="{whatever pixel you set}" height="[whatever pixel you set}"

and will render:

Quote
....... width=" width="{whatever pixel you set}""  height=" height="{whatever pixel you set}""

just a PSA!!!  thanks for the tip whomever wrote the original!!!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,951
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #34 on: February 07, 2019, 09:47:40 AM »
It’s also implemented in 2.1 in a slightly different way.