Advertisement:

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

Offline Reflection

  • Full Member
  • ***
  • Posts: 503
  • Gender: Male
    • Wii Powered
SMF 2.0:

Open ./Sources/Load.php

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

Replace with:
Code: [Select]
// 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:
Code: [Select]
                'local_time' => timeformat(time() + ($profile['timeOffset'] - $user_info['time_offset']) * 3600, false),
        );

        return true;

Replace with:
Code: [Select]
                '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]

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,152
    • @fragicide on Twitter
Nice idea :)

Would you like this moved to Tips and Tricks?

Offline Reflection

  • Full Member
  • ***
  • Posts: 503
  • Gender: Male
    • Wii Powered
Go right ahead. Thanks. :)
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]

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,152
    • @fragicide on Twitter
Moved :)

Offline JeremyB.

  • Jr. Member
  • **
  • Posts: 298
  • Gender: Male
  • $phpJeremyB;?>
Nice tip.
"The most overlooked advantage to owning a computer is that if they foul up, there's no law against whacking them around a little."

Offline N3RVE

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,906
  • Gender: Male
    • N3RVE.COM
Indexed as it wasn't :)

-[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 JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,152
    • @fragicide on Twitter

Offline Sabre™

  • SMF Hero
  • ******
  • Posts: 2,527
  • Gender: Male
  • IF IT AINT BROKE, I CAN FIX IT TILL IT IS!!
I wonder if replacing the blank.gif in your avatar folder with a default one would work. :)

*goes back to sleep
« Last Edit: July 22, 2009, 06:22:26 PM by Sabre™ »
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


Offline Hassan_the best

  • Full Member
  • ***
  • Posts: 592
  • Gender: Male
  • Lost in life
Nice


Offline Sabre™

  • SMF Hero
  • ******
  • Posts: 2,527
  • Gender: Male
  • IF IT AINT BROKE, I CAN FIX IT TILL IT IS!!
Yeah, thats what I use
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


Offline Reflection

  • Full Member
  • ***
  • Posts: 503
  • Gender: Male
    • Wii Powered
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]

Offline Costa

  • SMF Hero
  • ******
  • Posts: 3,045
  • Gender: Male
  • Do NOT feed the trolls...
Cool tip!

Thanks Reflection!
Hugo "Costa" Fernandes
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."

Offline Nibogo

  • SMF Hero
  • ******
  • Posts: 6,638
  • Gender: Male
    • smfpacks on Facebook
    • @smfpacks on Twitter
    • SMFPacks
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. ;)

Please tell me where do you see a template edit, the mod do the same also edits the Load.php file:

http://custom.simplemachines.org/mods/index.php?action=parse;mod=975;attach=54824;smf_version=1.1.4

;)

Offline Reflection

  • Full Member
  • ***
  • Posts: 503
  • Gender: Male
    • Wii Powered
./Themes/default/ManageAttachments.template.php

:P
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]

Offline Nibogo

  • SMF Hero
  • ******
  • Posts: 6,638
  • Gender: Male
    • smfpacks on Facebook
    • @smfpacks on Twitter
    • SMFPacks
./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) ;)

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,136
  • Master of BBC Abuse
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.

Offline Nibogo

  • SMF Hero
  • ******
  • Posts: 6,638
  • Gender: Male
    • smfpacks on Facebook
    • @smfpacks on Twitter
    • SMFPacks
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.

Because if you want to change the avatar you don't need ftp access (for example in my iPod)

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,136
  • Master of BBC Abuse
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.

Offline robinrobin

  • Jr. Member
  • **
  • Posts: 297
Re: [Tip/Trick] Making a "real" default avatar (Eg: without editing templates)
« Reply #19 on: September 19, 2009, 04:15:45 PM »
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.