Implement Gravatar for your theme

24 Aug 2009

If your theme supports the get_header_image or header_image function in wordpress you can modify it so that it uses a Gravatar instead.

Edit the wp-includes/theme.php file and find the function get_header_image and change it so it looks like this

/**

  • Retrieve header image for custom header.

*

  • @since 2.1.0
  • @uses HEADER_IMAGE

*

  • @return string

*/

function get_header_image( $gravatar = False ) {

if( !$gravatar )

{

return get_theme_mod(‘header_image’, HEADER_IMAGE);

}

else

{

$email = ”;

$tm = mktime();

return “‘http://www.gravatar.com/avatar.php?gravatar_id=”. md5( strtolower(‘$email” ) ) .”&size=110?antiCache=$tm’” ;

}

}

Then modify the header_image function so it looks like this

/**

  • Display header image path.

*

  • @since 2.1.0

*/

function header_image( $gravatar = False ) {

echo get_header_image( $gravatar );

}

Now all you have to do is find in your theme where it uses the header_image function or get_header_image and change it so that it just says

header_image( True ) or get_header_image( True ) depending on which one you use(they both do the same, one is just depricated

The image in the upper right is my gravatar

«« Previous Post Next Post »»