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

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

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

Avatar picture is broken

I've loaded and reloaded my picture into Gravatar, but it still displays as broken in my admin panel. Also, the email address for my Gravatar account is the same as the email address in my admin profile. It's displayed correctly in the past, so I'm not sure what happened to break it.
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

i1.wp.com url problem (Jetpack not installed)

I added the following code to the functions.php file add_filter( 'avatar_defaults', 'new_gravatar' ); function new_gravatar ($avatar_defaults) { $myavatar = 'link'; $avatar_defaults[$myavatar] = "name"; return $avatar_defaults; I'm taking the profile picture from my own server. But there is a problem! "I1.wp.com" appears at the beginning of the url in the profile image. What is the reason? So it looks like: "https://i1.wp.com/mysite.com/images/myavatar.png" I've disabled all plugins. But the result was not successful. I'm dealing with it in days. How do we delete …
Category: Web

Convert User's Avatar/Gravatar to a jpg or png on the Fly

Is there a way to convert a user's gravatar/avatar to jpg on the fly? I have the following in my function: get_avatar( $uid, 180 ); which returns the user's avatar image if I call it with straight PHP (i.e.: <?php echo get_avatar( $uid, 180 ); ?> but I want to convert the resulting file to a jpeg/png image so I can insert it into an FPDF function Cheers
Category: Web

Gender based user avatar

I'm creating a matrimonial website. I want to set the user avatar based on the gender(I have a custom_user_meta for the user's gender) But I don't understand how to get the "user id" in order to use the meta data "user_meta_gender"(to find out if the user is male or female). P.S: I'm not using buddypress, I'm using a plugin named Profile Builder Pro Also get_current_user_id does not work since it retrieves only the LOGGED IN users ID. ``This is the …
Category: Web

get_avatar filter is not working as per requirement

I have an author loop with a profile picture that saves into ACF custom fields and I want to use it as get_avatar but it returns blank. Here is a snippet: $get_avatar = get_user_meta($user->ID, "wp_user_avatar"); $avtar = add_filter( 'get_avatar', wp_get_attachment_image($get_avatar[0], 'thumbnail') , 10, 3 ); Now, <div class="profile-photo"><?php echo get_avatar($user, 100); ?></div> it shows blank div
Category: Web

Wrong gravatar showing up?

I've got an install that's loading the wrong gravatar and I can't figure out why. Most confusing is that it's doing it in the front-end templates AND in the admin. Here's a screen cap: The user and email listed are not mine, but the face is. Any idea how that's happening? Even since Gravatar and Jetpack and linked accounts and whatnot I've felt a little disconnected with how these images are actually conjured, but this is the first time it's …
Category: Web

How to check if gravatar of user is the default's one?

I am looking for a way to check if the user has the default gravatar. It doesn't work if I use a simple get_avatar( current_user_id() ) === false as the default gravatar is still an avatar so it never returns false; It doesn't work either if I check the get_avatar_data( get_current_user_id() )['found_avatar'] as it returns 1 even with default gravatar. Do someone has an idea? Thanks for your help!
Category: Web

Custom Field Repeating When Using foreach

I'm trying to display user avatars by login user name using custom fields like this - And here's the code - function user_avatar() { $name = get_post_meta( get_the_ID(), 'user_name', true ); $users = get_user_by( 'login', $name ); foreach( (array) $users as $user ) authors(); } function authors() { $gravatar = get_avatar( $user->user_email , 32 ); echo $gravatar; } However, this code repeats avatars in addition to the only one i want printed. I need to print only the avatars where's …
Category: Web

About

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