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

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

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

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

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

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

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

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

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.


1

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.


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

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

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

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



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