7

I think the problem is simply that your default avatar isn't publicly available. Try for example http://upload.wikimedia.org/wikipedia/en/b/b0/Avatar-Teaser-Poster.jpg instead of http://loalhost:888/wordpress/wp-content/themes/blog-theme/img/icons/avatar.jpg Notice that the default gravatar is served via http{|s}://i{0,1,2}.wp.com/... From the docs: ...


6

Presuming that the user has their avatar saved, as the ID of an attachment, store in user meta, as the field field_with_custom_avatar_id, you could do this to show that attachment if the value is saved: add_filter( 'get_avatar', 'slug_get_avatar', 10, 5 ); function slug_get_avatar( $avatar, $id_or_email, $size, $default, $alt ) { //If is email, try ...


6

As an alternative to my other answer, you can also use the get_avatar filter. Props to Sumit to alerting me to this one. The benefit of using the get_avatar filter is your custom avatar should be applied anywhere Wordpress uses it, rather than just in this users list like my other answer deals with. If you use plugins that display user avatars, this ...


5

You can simply disable gravatars in Settings > Discussion > Avatar Display. On technical side avatar links are produced by get_avatar(), which passes output through filter of same name and so can be easily hooked into without any need to edit core files. Also note that whole function itself is pluggable, meaning it can be completely overridden by being ...


5

Just generate the URL yourself. It's just a hash of the user's email address. function get_gravatar_url( $email ) { $hash = md5( strtolower( trim ( $email ) ) ); return 'http://gravatar.com/avatar/' . $hash; } This function requires that you pass the user's email address in ... but you could do anything you need to programatically grab the user's ...


4

I successfully replaced all gravitar.com avatars with my own locally hosted avatar image by adding this to my theme's function.php file: define('DEFAULT_AVATAR_URL', get_template_directory_uri() . '/images/user.png'); function no_gravatars( $avatar ) { return preg_replace( "/http.*?gravatar\.com[^\']*/", DEFAULT_AVATAR_URL, $avatar ); } add_filter( '...


4

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. Hope that this helps out someone in the future.


4

Notice: get_the_author_ID is deprecated since version 2.8! Use get_the_author_meta('ID') instead. in C:\Users\Administrator\Desktop\www.wpsites.dev\wp-includes\functions.php on line 2908 You aren't using get_the_author_meta('ID'); as instructed by the Notice. You are just using get_the_author_meta(). The latter returns an empty string when I try it. ...


4

The hook you need is the get_avatar filter. It returs the image HTML element representing the user avatar. add_filter( 'get_avatar', 'cyb_get_avatar', 10, 5 ); function cyb_get_avatar( $avatar = '', $id_or_email, $size = 96, $default = '', $alt = '' ) { // Replace $avatar with your own image element, for example // $avatar = "<img alt='$alt' src=...


3

I can understand that you don't want to remove support for avatars entirely. In this case, I'd recommend using a plugin such as WP User Avatar or Simple Local Avatars. Those will allow your users to upload their own avatars to your WordPress site instead of using Gravatar.


3

Basic setup <?php $args = array( 'orderby' => 'nicename' ); $users = get_users( $args ); foreach ( $users as $user ) { $avatar = get_avatar( $user->ID, '80' ); echo '<li><a href="' . $user->user_url . '">' . $avatar . '<br />' . $user->...


3

You can use get_avatar. The following example prints an avatar in 96 px, assuming that you have the user id stored in $user_id, and prints a fallback user.png if no such user or image could be found. echo get_avatar($user_id, 96, get_stylesheet_directory_uri() . '/images/user.png');


3

OK, so there are some occurrences of get_avatar() in your site. If you'll take a look at docs for this function, you'll see, that: you pass URL for default avatar image as 3rd param, you pass args as 5th param. And one of these args is: force_default (bool) (optional) Whether to always show the default image, never the Gravatar. Default: false. And ...


2

Look at how it is implemented here: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/pluggable.php#L1578 Additionally check out the very simple Gravatar API: http://en.gravatar.com/site/implement/images/ You can try to hook into the get_avatar filter and preg_match against the 'src' like so: add_filter( 'get_avatar', function( $avatar ) { ...


2

Unfortunately at moment Gravatar service itself only accepts single number for size and only serves square images. So you have to achieve it with CSS or download, modify and cache images.


2

I figured this out. The server I am working on doesn't have access to the outside. So, even though the image is in my template folder, the gravatar.com call in front of the image path was causing the error.


2

Your code actually works, it is just that you can't do what you want. The way gravatar works is by serving the image if it has one and redirecting to the supplied default if it doesn't, so even if the default is on your server you still can't avoid the redirect. And gravatar really makes your site load faster makes your server less loaded enables the ...


2

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( $...


2

You can just update the option field avatar_default to your new image url: add_filter( 'avatar_defaults', 'mytheme_default_avatar' ); function mytheme_default_avatar( $avatar_defaults ) { $avatar = get_option('avatar_default'); $new_avatar_url = get_template_directory_uri() . '/images/default_avatar.png'; if( $avatar != $new_avatar_url ) {...


2

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' ) to modify the email ...


2

When looking at the source of get_avatar(), you can see that it takes either ID or email as 1st argument: get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ); The source of get_the_author_meta() shows that it will return data for the following fields: 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ...


2

We could also use one of the following filters, available since WordPress 4.2: pre_get_avatar_data get_avatar_url get_avatar_data Regarding how to get the user ID from the $id_or_email we can see how it's done in the core: $email_hash = ''; $user = $email = false; if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) { $...


2

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 $...


1

Answer get_avatar($comment, 50, vol_random_image(), '', array('extra_attr' => 'nopin="nopin"')); Explanation Take a look at the get_avatar function: echo get_avatar( $id_or_email, $size, $default, $alt, $args ); Looking at this function, you'll notice the last parameter allowed is $args, which essentially lets you alter all values aside from $...


1

I've been looking up how to do this myself and that same function shown above everyone keeps suggesting isn't working, perhaps due to a recent update to WP's codebase, I'm not entirely sure. It's a little hackish and it involves editing core files (not good) but it's a work-around solution. Here's the steps: Use the same function specified in the original ...


1

You have the Photon module enabled in the Jetpack plugin. That module routes your images through WordPress.com's CDN. If you don't want this to happen, disable the Photon module in Jetpack.


1

It turns out there was something wrong with the uploads folder. If anybody has this issue in the future, this is what to do. Deactivate BuddyPress. chmod 777 uploads/ Reinstall BuddyPress chmod 775 uploads/ That was all it was.


1

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 ); ?>


1

Yeah it is possible. Just add a function to the get_avatar hook function change_avatar($avatar, $id_or_email, $size, $default, $alt) { return 'url_to_your_retro_image'; } add_filter('get_avatar', 'change_avatar', 10, 5);


Only top voted, non community-wiki answers of a minimum length are eligible