Tag Info

Hot answers tagged

7

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


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

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

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

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


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

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

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

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.


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

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

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

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

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


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

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

If I understand correct, you don't want people to upload a custom avatar, but you do want people to be able to link to a custom avatar? (and, if not, a default avatar or gravatar kicks in) If that's the case, this article will probably suit your needs http://www.billerickson.net/wordpress-custom-avatar/


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.


1

It's fairly simple to construct the Gravatar URL yourself, it's just an MD5 hash of the user's email address. <?php $gravatar = 'http://www.gravatar.com/avatar/' . md5(strtolower($email)) . '&s=32'; ?> <div class="avatar" style="background: url(<?php echo $gravatar ?>);" ></div> The s parameter at the end there defines the ...


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

As informed by @Rarst, apparently currently Gravatar only accepts one value for size. It is really unfortunate. However I managed to work-around this by facilitating timthumb.php and a function I found from here: How to get gravatar url alone I'm not sure if this is the best way to do this (it looks messy), however this works for me for creating 60x40 px ...


1

Here's a simple example showing default avatars and lists all users with the role of author. foreach ( get_users( array( 'role' => 'author' ) ) as $user ) { echo get_avatar( $user->ID ,'96' ,get_stylesheet_directory_uri().'/default-avatar.png' ,$user->nice_name ); }


1

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.


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



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