I previously described how to display Twitter author avatar when using Tweet Import which detailed how to edit your template to include the Twitter user image URL added as a custom field for imported tweets.
But in case you are using a theme such as P2, and would like to change the Avatar displayed without editing the template files, below is a hack that allows you to do that.
To achieve this, please add the following to your theme “functions.php” file.
if (!has_filter ('get_avatar', 'tweetimport_display_avatar')) {add_filter('get_avatar', 'tweetimport_display_avatar');}
if (!function_exists('tweetimport_display_avatar')):
function tweetimport_display_avatar($avatar)
{
global $post;
global $in_comment_loop;
if (in_the_loop() && !$in_comment_loop):
$twitter_avatar = get_post_meta($post->ID,'tweetimport_author_avatar' , true);
if (!isset($twitter_avatar) || $twitter_avatar == '')
return $avatar;
return preg_replace ('/<img(.*?)src=["|\'](.*?)["|\'](.*?)>/i', '<img$1src="'. $twitter_avatar . '"$3>', $avatar);
else :
return $avatar;
endif;
}
endif; //tweetimport_display_avatar
This code just applies a custom ‘get_avatar’ filter that substitutes the avatar URL generated by WordPress with the ‘tweetimport_author_avatar’ which is a custom field created by Tweet Import and whose value is the URL to the Twitter User image.

Comments
Hmm..for some reason I’m getting parse errors when copying this code (or the code of the @TwitterName hack) into my themes functions. I’m using the Aparatus theme. Any idea’s??
Never mind my previous comment. It had something to do with the theme I used. Your hack works.
@Dinho
Glad it worked… THX for the update
a hola como estan quiero se3r un usuari en twitter
@Nadia
Can you please help me find out how I can help.
I have to confess… My Spanish is as good as the google translator and translating your comment (a hello as I se3r are a twitter user) did not help
Is it possible to call this function from a specific place? (on an index with only an excerpt for example?)
Thanks!
@Mark
After adding this code to your theme “functions.php” file, this filter should change the avatar for all users. You do not need to call this function by hand.
Am I missing something here?