News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

[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

Reflection

SMF 2.0:

Open ./Sources/Load.php

Find:
// First do a quick run through to make sure there is something to be shown.
$memberContext[$user]['has_messenger'] = false;


Replace with:

// Default avatar. ^^
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 . '" />';

// First do a quick run through to make sure there is something to be shown.
$memberContext[$user]['has_messenger'] = false;


The default avatar should be uploaded to ./Themes/[your_theme]/, it should be named default_avatar.png and it should obviously be in .png format.

SMF 1.1.x:

Open ./Sources/Load.php

Find:
                'local_time' => timeformat(time() + ($profile['timeOffset'] - $user_info['time_offset']) * 3600, false),
        );

        return true;


Replace with:
                'local_time' => timeformat(time() + ($profile['timeOffset'] - $user_info['time_offset']) * 3600, false),
        );

// Default avatar. ^^
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 . '" />';

        return true;


Good "SMF" Portals
Tiny Portal [SMF 1.1.x only]
Simple Portal [SMF 1.1.x and 2.0]


Good "SMF" Theme Sites
SMF Themes [SMF 1.1.x and 2.0]
Dziner Studio [SMF 1.1.x and 2.0]

JBlaze

Jason Clemons
Former Team Member 2009 - 2012

Reflection

Good "SMF" Portals
Tiny Portal [SMF 1.1.x only]
Simple Portal [SMF 1.1.x and 2.0]


Good "SMF" Theme Sites
SMF Themes [SMF 1.1.x and 2.0]
Dziner Studio [SMF 1.1.x and 2.0]

JBlaze

Jason Clemons
Former Team Member 2009 - 2012

JeremyB.

"The most overlooked advantage to owning a computer is that if they foul up, there's no law against whacking them around a little."

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

JBlaze

Jason Clemons
Former Team Member 2009 - 2012

Sabre™

I wonder if replacing the blank.gif in your avatar folder with a default one would work. :)

*goes back to sleep
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)




Sabre™

Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


Reflection

Quote from: NIBOGO on July 22, 2009, 05:40:36 PM
Default Avatar?

Again, this edit makes the default avatar appear EVERYWHERE without editing any templates.. That mod edits templates, and the default avatar wouldn't appear everywhere. ;)
Good "SMF" Portals
Tiny Portal [SMF 1.1.x only]
Simple Portal [SMF 1.1.x and 2.0]


Good "SMF" Theme Sites
SMF Themes [SMF 1.1.x and 2.0]
Dziner Studio [SMF 1.1.x and 2.0]

Costa

Hugo "Costa" Fernandes - PT SMF
Todas as MP's a pedir ajuda são sujeitas a radioactividade, microondas, queimadas e atiradas borda fora.

"At least someone appreciates the fact that I am doing and not thinking..."
"Laziness is counter-revolutionary."


Reflection

Good "SMF" Portals
Tiny Portal [SMF 1.1.x only]
Simple Portal [SMF 1.1.x and 2.0]


Good "SMF" Theme Sites
SMF Themes [SMF 1.1.x and 2.0]
Dziner Studio [SMF 1.1.x and 2.0]

Nibogo

Quote from: Reflection on July 22, 2009, 06:27:29 PM
./Themes/default/ManageAttachments.template.php

:P

That is to set the image url nothing else, the image will appear everywhere, obviouslly if you can change the url from the admin panel (requires the edit of that file only used by the default theme) it's a lot better than modify the code (like your trick) ;)

Antechinus

Can't see how it is a lot better. Most sites will only set a default avatar once. Load one image. All done. No problem.


Antechinus

Meh. Like I said, default avatars are usually a once-only thing anyway. Both ways of tackling the problem seem more or less equally good to me. Can't see that one is hugely better than the other. The only thing I could see as an improvement to Reflection's idea is to call the default avatar from the default/images folder, or even from the site's images folder. That way if you are using multiple themes to give your users some choice you still only need to deal with one image.

robinrobin

Well this trick doesn't make the avatar appear in the left container in the collapsible personal space at the top of the forum with the default style. Maybe there should be some more edits. Making newly registered members see a difference when they actually are logged in is the only thing i wanted from this trick.

Advertisement: