[Tip/Trick] Making a "real" default avatar (Eg: without editing templates)

Started by Reflection, July 13, 2009, 06:36:12 PM

Previous topic - Next topic

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

C4G-TK

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-

Nier

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..

curlin

     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!.

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

Veliki Brat

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

flapjack

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

sona67

Quote from: Veliki Brat on February 24, 2010, 04:03:02 PM
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


Xarcell

How come this doesn't work in the index.template.php, it works everywhere else?

Antechinus


Xarcell

I think it's because member is not defined for some reason. I will attempt to debug...

Xarcell

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:
QuoteUndefined index: image
in whatever template file is being viewed

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

Arantor

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.

drewactual

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:

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:

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

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!!!

Arantor


Advertisement: