Sign Up! Login: Password: New User? Forgot? Support
Code 
 
 
Forums 
Forums : Widgets > Replace Missing Avatars
Mottie (SuperAdmin) 7/2/2011 12:51 PM EST : Replace Missing Avatars
ACK!
Mottie
Posts: 3884

0
Like

0
Dislike

Replace Missing Avatars

GuildPortal admin site link to the original post

If you want to replace the avatar for the Member of the Month widget, you might need to use this code. I can't find anyone using it to test this code on 

So far this replaces missing avatars with a random one from the list. So far this code works in the shout box, officer contacts and new members widgets. It can potentially replace more.

Code
Add the following code to your custom scripting (Control Panel > Custom HTML & Script > Custom Javascript/jQuery > Document Ready Event)
var avatars = [
 'http://www.axiomfiles.com/Files/278466/avatar-Animal.jpg',
 'http://www.axiomfiles.com/Files/278466/avatar-bender.png',
 'http://www.axiomfiles.com/Files/278466/avatar-dalek.png',
 'http://www.axiomfiles.com/Files/278466/avatar-Gollum.jpg',
 'http://www.axiomfiles.com/Files/278466/avatar-hello-kitty2.png',
 'http://www.axiomfiles.com/Files/278466/avatar-snorlaxv.png'
];
// ***********************
// Don't change anything below
// ***********************

$('img[src*="empty-profile.png"]').each(function(){
 var rndm = Math.floor( Math.random() * (avatars.length) );
 $(this).attr('src', avatars[rndm]);
});
$('.gpWidget-officercontacts table.StyledList tbody tr').each(function(){
 var rndm = Math.floor( Math.random() * (avatars.length) );
 $(this).find('td:first:empty').html('<img align="left" style="height:32px;width:32px;border-width:0px;margin-right:3px;" src="' + avatars[rndm] + '">');
});
Customizing
  • Replace, or add more image urls (in orange) to pick from when replacing missing avatars.
  • Make sure that all lines, but the last, ends with a comma.
Characters: Mottie Motty Mortie Ooshiny Mot Fudgems
TopBottom

 
 
Key 
New posts No new posts
New posts ( popular ) No new posts ( popular )
New posts ( sticky ) No new posts ( sticky )
New posts ( locked ) No new posts ( locked )
 
 
Who's Online 
There are   members online.
 
 
So-and-so has logged on!
%title%
%message%