Apply a filter on get_avatar, it takes 5 arguments (!). The first one is the complete <img>-tag. And do not forget the source can be enclosed with double and single quotes ( ["|'] ). I guess that was the point where your function failed.