Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to set your own custom default avatar, when users have no gravatar


  • buddha-trance
    Member

    @buddha-trance

    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

    case 'blank':
    $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”.

    Voila!!!!

    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!

Viewing 2 replies - 1 through 2 (of 2 total)

  • Ben L.
    Member

    @nightgunner5

    Because it’s in functions.bb-pluggable.php, you can copy the function into a plugin file and edit it from there. No work needed when upgrading, and it can be turned on and off.


    buddha-trance
    Member

    @buddha-trance

    @Nightgunner5 – Thank you for the tip. I will try to do as you suggest. It’s so much better to leave the core files in their original state. I have never tried to create a plugin, this is a good reason to start! :-)

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar