free hit counters
If you are using Internet Explorer as your browser please be running at least IE 7 or above. This site does not support IE 6 or below. Go here for the latest free version including easy download and installation instructions If you want to make it real easy on yourself, download Firefox , the most popular browser in the world. It's free and simple. You'll be so glad you did.
Mar
18
2009

Add avatar to wordpress default

You can add your own image to the default list of avatars listed in Dashboard —-> Settings —-> Discussion….

136

135

I came across this code and it works perfectly. Add the following code to your custom_functions.php file…

/*add avatar to wordpress default list*/
add_filter( ‘avatar_defaults’, ‘newgravatar’ );
function newgravatar ($avatar_defaults) {
$myavatar = get_bloginfo(’template_directory’) . ‘/images/name-your-gravatar-image.jpg’;
$avatar_defaults[$myavatar] = “administrator”;
return $avatar_defaults;
}

The add_filter function says that we’ll be editing the avatar_defaults array using our custom function “newgravatar

The newgravatar function details the location and title of our additional gravatar option

$myavatar = get_bloginfo(’template_directory’) . ‘/images/name-your-gravatar-image.jpg’; points to the new gravatar in the images folder of the template directory

The line after that designates the name that will be displayed next to the image dashboard options. I just happened to name mine administrator, you can name it whatever you want

The third line sends back the results to the avatar_defaults array to be included in the theme

Leaving a comment with code in it...

If you would like to leave a comment and you have examples of code you want to show, you must "escape the code". This allows the entire code to show correctly by inserting certain variable around certain tags to make them show. If you don't "escape the code" your code will show up broken, mangled, and it won't be able to be seen correctly. "Escaping the code" is very simple...

  1. Copy your code you want to show
  2. Click here to go to the site to escape the code
  3. Follow the directions, it's so easy
  4. Once you have the escaped code copied, paste it in the comments area where you want
  5. Now you can enjoy life


Go ahead, leave a comment...

{ 1 trackback }

/var/log/fred » Blog Archive » First up, Thanks!
March 30, 2009 at 6:27 pm

{ 2 comments… read them below or add one }

Mati April 30, 2009 at 9:13 am

I accidentally found your site and it’s kind of luck hoping you can help me out of a problem concerning the avatat. I’d like to replace avatar in comment with avatars uploaded by WPMU users. I have been waiting for the solution on thesis site but noone can figure this out It will be very kind of you to get me a solution. Thanks in advance.

Here is the link I posted my question.
http://diythemes.com/forums/customization/5919-how-replace-new-avatar-code-comments-php.html

Reply

Nasty May 1, 2009 at 6:29 pm

The code that you have should be placed in the custom_functions.php file. If you have it working by putting it in the comments.php file it should work being that it is “in the loop”. This way you will always have it upgraded when you upgrade your thesis versions down the road.

Reply

Leave a Comment

Previous post: Add shadow border to your blog page

Next post: Add an image with a widget