Tag Info

Hot answers tagged

8

If you want a super-lightweight solution and don't mind dabbling in a little code, drop this in your functions.php; function __default_local_avatar() { // this assumes default_avatar.png is in wp-content/themes/active-theme/images return get_bloginfo('template_directory') . '/images/default_avatar.png'; } add_filter( 'pre_option_avatar_default', ...


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


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


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


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 />' . ...


3

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.


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

If you look at the Gravatar API you will see that you can call a user specific and specify a default so here a built proof way to get the the image url in your code. $email = $comment->comment_author_email; $size = 60; $rating = get_option('avatar_rating'); $default = urlencode( 'http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . ...


3

Plenty of info on WP Codex on Gravatar's. use: get_avatar( "id of author" );


3

If you're in the Loop: echo get_avatar( get_the_author_meta('ID') );


3

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


2

Your if will always return true and bypass your custom author pic. Run the if on the custom field. If it returns true then add a filter to get_avatar that uses the custom field author pic. if ( the_author_meta('author_pic') ) { add_filter( 'get_avatar', 'your_custom_author_pic_function' ); }


2

You need to use get_the_author_meta() instead of the_author_meta() <?php $authorpic = get_the_author_meta('author_pic'); if ($authorpic) echo $authorpic; else echo get_avatar( get_the_author_email(), '80' ); ?>


2

There is a sweet new plugin I recently discovered called Simple Local Avatars that will do exactly what you ask. Check it out!


2

Try the Simple Local Avatars Plugin. It works exactly as advertised!


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


2

It depends on what you call "nice" of course - it's hard to create something meaningful with an algorithm. Someone once created a unicorn-generator, which was used on April 1, 2010 all over Stack Overflow. Your unicorn looks like this:


2

Quite simple, actually: wp_list_comments( 'avatar_size=80' ); Just change avatar_size=80 to whatever is appropriate. Here's a bit more information on customizing Gravatars in WordPress.


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


1

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


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

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

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

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


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


1

<?php add_filter( 'get_avatar', 'get_avatar_url', 10, 5 ); function get_avatar_url( $avatar, $id_or_email, $size = 96, $default = '', $alt = '' ) { preg_match( '#src=["|\'](.+)["|\']#Uuis', $avatar, $matches ); return ( isset( $matches[1] ) && ! empty( $matches[1]) ) ? (string) $matches[1] : ''; } Apply a ...


1

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


1

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


1

If you are looking to connect your sites sign-up with Gravatar then you simply can't, since Gravatar don't have a sing-up api you can use. But if you are just looking to let your users upload there own photos the either Simple Local Avatars Plugin that Chip suggested or one I've used a lot before is User Photo will do the job just fine. But the better part ...



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