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

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


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

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

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

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

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

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


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

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

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

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

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

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

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!


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


1

Mark Jaquith a WP core developer wrote a plugin called Gravatar Signup which checks if the user has a Gravatar when the leave comments (and maybe when the first signup) and if not shows a link to the gravatar site. They would still need to sign up at Gravatar.com but this may be a simple fix to your problem. Personally I try to stay away from plugins that ...


1

The only other one supported by Gravatar is the retro generator. This is built into newer versions of WP, just select it in Settings->Discussion.


1

By default WordPress does not display an avatar for a pingback or a trackback - do they even contain an e-mail address? You can add these to the get_avatar_comment_types filter if you want to change this.


1

From the core: function get_user_meta($user_id, $key, $single = false) { return get_metadata('user', $user_id, $key, $single); } Pass the user id as the first argument, the key 'author_pic' as the second and TRUE as the third (to get a string value back).


1

Your code in the edit part of the question should work, and also your first part but you need to add the user ID to get_user_meta() function so use your first code but change the first line to this: $profilepic = get_user_meta($user_id,'author_pic',true); and make sure $user_id hold the user's actual ID.



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