Show custom default avatar instead of gravatar

I'm using this custom function to get the default avatar from my server instead of gravatar: if(!function_exists('custom_avatar')){ function custom_avatar($avatar_defaults){ $new_default_icon = 'http://localhost/gv/wp-content/images/mystery-man.png'; $avatar_defaults[$new_default_icon] = 'Custom Avatar'; return $avatar_defaults; } add_filter('avatar_defaults','custom_avatar'); } but the custom avatar is not showing up, when I view source code then the src of the image look like this: http://0.gravatar.com/avatar/a432e8915b383edd8d25c2a4fd5a6995?s=32&d=http%3A%2F%2Flocalhost%2Fgv%2Fwp-content%2Fimages%2Fmystery-man.png%3Fs%3D32&r=G&forcedefault=1 Why does my image src relative to gravatar here? How can I fix this problem?
Category: Web

User avatar-ACF fields

I'm running wp multisite and using ACF custom field (user edit) for my local avatar, in my functions.php i added : add_action('get_avatar', 'tsm_acf_profile_avatar', 10, 3); function tsm_acf_profile_avatar( $avatar, $id_or_email, $size, $default, $alt ) { $user = ''; // Get user by id or email if ( is_numeric( $id_or_email ) ) { $id = (int) $id_or_email; $user = get_user_by( 'id' , $id ); } elseif ( is_object( $id_or_email ) ) { if ( ! empty( $id_or_email->user_id ) ) { $id = …
Category: Web

How to give users a fixed gallery of avatars to choose from?

I have the exact same question as the gentleman who started this thread a year ago: https://wordpress.org/support/topic/possible-to-give-users-a-gallery-of-avatars-to-choose-from/ — that is, “I’m looking for a way to give users a limited number of avatars to choose from. More specifically, – I want to disable Gravatar – I do NOT want them to be able to upload an avatar – I do NOT want to have one single default avatar that everyone gets with no choice – I want to provide them …
Category: Web

Conditional avatar

I am using a plugin that allows users to upload profile graphics in place of avatars. The plugin is "User Avatar". I am displaying user profile graphics with this code: echo get_avatar( get_the_author_meta('user_email'), $size = '60') It works fine except I would like it to function so that, if a user does not have a user profile graphic, it defaults to display nothing. If I use the avatar Discussions settings to display "Blank" when there is no user avatar I …
Category: Web

Alternative default avatar generator?

Most of the commenters at my WordPress blog do not have a Gravatar account. Hence the comment section is almost always filled with the same old mystery man avatars. I am looking for custom gravatar generators for commenters without their own avatar. So far I have only found Identicons, MonsterID’s, and Wavatars. I find some of the avatars generated by these engines to be these ugly, scary and OTT. Also these do not blend with the blog theme and stick …
Category: Web

How to output nothing instead of default avatar?

I am looking for a solution to output nothing instead the default avatar when a user does not have any avatar. I am currently using this line. I looked at the function and the only thing I got so far is to use blank as default avatar but its still occupies space and I do not want that. echo get_avatar( get_the_author_meta( 'ID' ), 70, 'blank', __( 'avatar', 'bla' ) ); Sidenote: Even that blank avatar gets pulled from Gravatar, I …
Category: Web

Display post author avatar for Ultimate Member

I want to show avatar from the post author. I use Ultimate Members and want to show the avatars that are defined via UM. <?php global $post; $url = get_avatar_url( $post, array( 'size' => 48 )); $img = '<img alt="" src="'. $url .'">'; echo $img; ?> But this code shows the gravatars or default avatar. How can I get the avatars from Ultimate Member?
Category: Web

How do I add nopin="nopin" to the default avatar?

I noticed that if someone clicks on my Pinterest share button on a blog post, several unrelated images show up. I was able to use nopin="nopin" per Pinterest's documentation on most of these images to clean most of it up. However, I have a custom avatar set in my functions.php... //* Add new default gravatar to Settings » Discussion page */ add_filter( 'avatar_defaults', 'wpb_new_gravatar' ); function wpb_new_gravatar ($avatar_defaults) { $myavatar = 'https://www.fakedomain.com/wp-content/uploads/2017/03/PiggyBank.jpg'; $avatar_defaults[$myavatar] = "Default Gravatar"; return $avatar_defaults; } If …
Category: Web

Get only the author profile picture image url inside a loop

I need to get the post author profile picture link. I know I can use get_avatar(); but it displays whole image markup <img src="http://.../img.png" class="avatar img-responsive" alt="image"> But need only the src of the author profile pic. How can I got that ? Maybe we can use some php or js to take out the only src value from the total output. My second question is, how can I add that image as post_thumbnail if no thumbnail exist for that …
Category: Web

Adding an Avatar to the Top Nav Bar

I am attempting to add an avatar image to the top nav menu. I am currently using this function, which takes a custom link and replaces it with the currently logged in user's name. That part of the function works excellent. My attempts to modify the function haven't gotten me across the finish line yet. Yes, there is a question on here that is kind of similiar, Inserting PHP before a menu element, while using the inbuilt menu function wp_nav_menu(), …
Category: Web

Display avatar of user profile when logged in

I am trying to display user's avatar/profile image when logged in, but when I use this: <?php global $current_user; get_currentuserinfo(); echo get_avatar( $current_user->ID, 64 ); ?> it displays the default_avatar_male.jpg, but I don't want anything to be displayed unless logged in. Thanks for all help.
Category: Web

How to get authors avatar

How do I get the authors avatar? Buddypress plugin or any plugin. I have found this inside my PHP code: "<i class="fa fa-user"></i><span>'.get_the_author().'</span></div>';" It shows a small image before the author's name, I wanted to change the fa fa-user into author's avatar or buddypress avatar. What will be the script to do that?
Category: Web

How do I get a smaller size of an avatar image

I have a function that creates a bio-line at the top of every post. One part gets the avatar of that user, that he uploaded in WordPress (I use a plugin so people don't need to use Gravatar for this). function mm_author_byline() { if (is_single() AND (get_post_type() == 'post' OR get_post_type() == 'theme_product_review')) { ?> <div class="mm-byline-image"> <?= get_avatar(get_the_author_meta('ID')) ?> </div> <?php } } The problem now is, that this image is neither cropped, nor is it sized down. It …
Category: Web

get_avatar() is not working in my custom theme

I have used this code to display author image. It was working in Local By FlyWheel but isn't working on a live site. It's not working means that it is not producing any HTML. <?php $post_id = get_the_ID(); $author_ID = get_post_field( 'post_author', $post_id ); echo get_avatar( $author_ID, 32); ?>
Category: Web

Syncing Avatars across multisite

There's gotta be a way. I have tried a bunch of different multisite sync plugins and they sync users and roles just fine (even paid for plugins to do so)....but avatars don't sync. My registration form handles the image upload just fine -- and assigns it to the user (but only on the one site the registration came from) -- and shows blank/no image/avatar on the rest. I've nearly been pulling my hair out on this and while I don't …
Category: Web

Simple Local Avatar Plugin

I think that Im very close to achieve my goal.. I have this function on my themes but I need a help to find the right way to call simple local avatar function so it will show the local avatar image from simple local avatar pugin instead wordpress gravatar? $first_img = get_avatar( $post->post_author ); Is there anyone can help? function get_post_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; …
Category: Web

Removing Gravatar.com support for WordPress and Simple Local Avatars

Currently I'm using Simple Local Avatars on several of my blogs allowing people to upload their own custom avatar. As far as I know Simple Local Avatars uses get_avatar to check whether a custom avatar is selected, if not defaults to Gravatar.com. Would it be possible to disable the Gravatar.com bit somehow, disabling Gravatar.com completely and returning just some local hosted image if no custom avatar is selected? I hope it would be OK to post this here, but this …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.