*

Recent

Author Topic: Different Default Avatar MOD  (Read 5381 times)

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Different Default Avatar MOD
« on: November 02, 2011, 05:28:58 AM »
This "MOD" is released under the GPL license.

This works a little different to the MOD by spaghettiokillers as it uses no Db queries for its functions. And the default on or off is still left up to the user.

This adds a default avatar for those who haven't bothered to add one. It also selects the avatar by sex for Male, Female and Undisclosed.

Open: your theme/showprofile.php

Code: [Select]
Find:

if ($avatar == "1" ) { $avatarfileurl = '<img src=\''.$domain.'/avatars/'.$avatarfile.'\' height=\'60\' width=\'60\' alt=\'\' />'; } else { $avatarfileurl = ''; };

Replace with:

$MyWidth = '80';
$MyHeight = '80';
if ($avatar == "1" ) { $avatarfileurl = '<img src="'.DIRPATH.'/avatars/'.$avatarfile.'"  style="max-width: '.$MyWidth.'px; max-height: '.$MyHeight.'px !important;" alt="" />';
} else {
if (empty($avatarfile) && ($sex == f) && ($avatar == "0" )){ $avatarfileurl = '<img src="'.DIRPATH.'/avatars/default/def-female.png"  style="max-width: '.$MyWidth.'px; max-height: '.$MyHeight.'px !important;" alt="" />';
} else {
if (empty($avatarfile) && ($sex == m) && ($avatar == "0" )){ $avatarfileurl = '<img src="'.DIRPATH.'/avatars/default/def-male.png"  style="max-width: '.$MyWidth.'px; max-height: '.$MyHeight.'px !important;" alt="" />';
} else {
if (empty($avatarfile) && ($sex == u) && ($avatar == "0" )){ $avatarfileurl = '<img src="'.DIRPATH.'/avatars/default/def-member.png"  style="max-width: '.$MyWidth.'px; max-height: '.$MyHeight.'px !important;" alt="" />';
}}}}


Save File:


Change the 80 in $MyWidth and $MyHeight to set either the maximum width or height allowed and the images will auto-resize proportionately.

You can rename the files if you wish - But I do suggest that you add them to avatars/default/*.*

I've also attached three avatars to get you started!  ;D
« Last Edit: November 02, 2011, 04:44:28 PM by mort »

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Different Default Avatar MOD
« Reply #1 on: November 02, 2011, 06:58:57 AM »
this is what i had done originally. Then i changed it so that you didnt have to edit the code when you wanted to change something.

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: Different Default Avatar MOD
« Reply #2 on: November 02, 2011, 04:42:40 PM »
I set that up originally to add it to the Settings but you did your thing and I didn't want to intrude.

But what this does is set the the avatars so that any-size images that are not proportional are not pulled out of shape.

And IF I was going to add it to Settings, All I would do is to give it an argument and add a switch to turn avatars on/off globally.

And also add options to set the width and height.

I would also alter the sex table to VARCHAR 14 and change all the f, m and u to Female, Male and Undisclosed.

That's what I would do - Or someone else can do it if they wish. ;)

As a matter of fact - I'll add licensed under the GPL to it, and people can do as they please with it. :)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Different Default Avatar MOD
« Reply #3 on: November 02, 2011, 04:57:56 PM »
is this a hint? lol

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: Different Default Avatar MOD
« Reply #4 on: November 02, 2011, 05:06:48 PM »
Help yourself. Lol!

Shouldn't be too hard for someone with your talent. ;)