How to set your own custom default avatar, when users have no gravatar
I am sharing this, just in case it may help someone else looking to implement this feature. There is a great plugin that does this, bbAvatars, but it was interfering with other functions I wanted to implement, so I had to find a workaround (bbPress 1.0.2).
With the premise that I really don’t like to edit core files, because you have to remember to edit them each time you upgrade, this time I had no choice, as any avatar plugin I tried did not work out for my purposes. There are a few simple steps you can use to set your own custom avatar, when users have not set a gravatar account.
1 – I have noticed that the “blank” choice in the settings is the only one that refers to an internal image, so you just want the code to point to your own custom image, rather than “blank.gif” (which may be also used for other calls, so I wanted to leave that one alone and not replace it with another custom blank).
In “bb-includes”, look for the file “functions.bb-pluggable.php”, and edit around line 895, where it says
$default = bb_get_uri( 'bb-admin/images/blank.gif', null, BB_URI_CONTEXT_IMG_SRC );
and change blank.gif with your image, default.jpg or any other name.
2 – Upload your custom image in bb-admin/images (if you store it somewhere else, change the path in the code above accordingly).
3 – In your Admin Dashboard –> Settings –> Discussions, set the choice to “blank”.
To change the avatar size from the bbpress default size, in post.php of your templates, look for
<?php post_author_avatar_link(); ?>
and add the number of pixels inside (), for example:
<?php post_author_avatar_link(80); ?>
Hope this helps!
You must be logged in to reply to this topic.