0815

Du musst dich anmelden um Beiträge und Themen zu erstellen. Einloggen · Registrieren

Add More Default Avatar Choices to the WordPress Admin

Here is a quick and easy way to add more default avatars to the list of available gravatars in the Settings area of the WordPress Admin. Here is the functions.php code to make it happen:

// add more default avatars to options
if (!function_exists('fb_addgravatar')) {
	function fb_addgravatar($avatar_defaults) {

		$myavatar1 = get_bloginfo('template_directory').'/images/avatar-01.png';
		$avatar_defaults[$myavatar1] = 'dude';
 
		$myavatar2 = get_bloginfo('template_directory').'/images/avatar-02.png';
		$avatar_defaults[$myavatar2] = 'geek';
 
		$myavatar3 = get_bloginfo('template_directory').'/images/avatar-03.png';
		$avatar_defaults[$myavatar3] = 'cool';

		return $avatar_defaults;
	}
	add_filter('avatar_defaults', 'fb_addgravatar');
}

See the innermost indented lines of code? There we are specifying three additional default avatars. To use this code, you will need to edit these lines to match your image paths and the name for each avatar. Hopefully the process of editing, adding, or removing avatars is clear. If not, don’t hesistate to speak up in the comments and someone will help you out.

Source: WPEngineer




0