Replace Gravatar with img URL for avatars

Unless I have misunderstood your question to accomplish a custom gravatar to use in your theme add the code below to your functions.php or into a custom plugin. From there customize the title and the image you want to use. See screenshot below for the finished outcome. add_filter( ‘avatar_defaults’, ‘dev_designs_gravatar’ ); /** * Display a … Read more

get the avatar url instead of an html img tag when using get_avatar?

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 size of the image in pixels. Using Gravatars – WordPress Codex

How to output nothing instead of default avatar?

You can use the get_avatar filter to change the output or avatar_defaults to add new image that can be placed on your server. Here is an example code for adding new avatar that you can set as default from the Settings > Discussion page. add_filter( ‘avatar_defaults’, ‘add_new_gravatar_image’ ); function add_new_gravatar_image($avatar_defaults) { $myavatar=”http://yoursite.com/image.png”; $avatar_defaults[$myavatar] = “Default … Read more

Listing all users by their avatars in wordpress

You can jump start by using following example. Here I’ll be listing users and loop through them to display avatar and display name. <?php $blogusers = get_users(); // Array of WP_User objects. foreach ( $blogusers as $user ) { /* Here passing user email and avater size */ echo get_avatar( $user->user_email , 96 ); echo … Read more

How to get gravatar url alone

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 … Read more