get_avatar won’t show uploaded avatar, only default gravatar
And of course as soon as I post the question, I find the answer. slaps forehead <?php global $current_user; get_currentuserinfo(); echo get_avatar( $current_user->ID, 48 ); ?>
And of course as soon as I post the question, I find the answer. slaps forehead <?php global $current_user; get_currentuserinfo(); echo get_avatar( $current_user->ID, 48 ); ?>
You can use pre_get_avatar filter to manipulate comment avatar html and stop WP from getting a default avatar for the comment. Passing a non-null value will effectively short-circuit get_avatar(), passing the value through the ‘get_avatar’ filter and returning early. E.g. add_filter( ‘pre_get_avatar’, ‘my_filter_pre_get_avatar’, 10, 3 ); function my_filter_pre_get_avatar( $avatar_html, $id_or_email, $args ) { if ( … Read more
From Gravatar.com: All URLs on Gravatar are based on the use of the hashed value of an email address (link) Instead of storing an email adress in the comment data, you can store the md5-hash of that email adress. The email adress is encrypted and you can use gravatars. Use the filter add_filter( ‘preprocess_comment’, ’email_to_md5′ … Read more
You can use the get_avatar_url filter (see the arguments passed here in the source code) to change the avatar url and then simply use get_avatar() with the user email in the theme as you’re used to. add_filter(‘get_avatar_url’, ‘wpse_avatar_or_gravatar’, 10, 3); function wpse_avatar_or_gravatar($url, $id_or_email, $args) { // was id passed via $id_or_email if ($id_or_email == intval($id_or_email)) … Read more
Debug ideas: You could try to see if this has any effect: add_filter( ‘bp_core_fetch_avatar_no_grav’, ‘__return_true’ ); But you should check out the parameters that go through the bp_core_fetch_avatar filter to see if they are correct (untested): add_filter( ‘bp_core_fetch_avatar’, ‘my_bp_core_fetch_avatar’, 99, 9 ); function my_bp_core_fetch_avatar( $html, $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir ) { … Read more
I think that i figured it out. Gravatar default images need to be on a public url and not one blocked by htaccess. So i had this on my dev server and when i removed my htaccess file that was blocking access the images started to work. This seems to still be a new feature. … Read more
Maybe I was burned out from work before, but this morning I took another go at the same code and managed to get it running properly. if ( ! function_exists( ‘comment_imgs’ ) ) { add_filter( ‘get_comment_author_url’, ‘comment_imgs’ ); function comment_imgs( $avatar, $id_or_email, $size, $default, $alt ) { global $comment; // We do not get the … Read more
Assign a random avatar to every user?
Gravatar by design doesn’t require the downstream system to be aware if there is a match. The image (if any) is determined and served on request, only hash needs to be provided. It’s impossible to “guess” from email or its hash if it has an avatar. That can only be resolved by request to the … Read more
Have a look at the Codex about “Using Gravatars”. There you´ll find a part about “Checking for the Existence of a Gravatar” which works like this: The trick to do this is to specify “404” as the default. In this case, the gravatar service will return a 404 error if no gravatar exists, instead of … Read more