如何在WordPress上更改默认Gravatar

Do you want to change the default Gravatar on your WordPress site? By adding your own default gravatar image, you can make your comments section branded. In this article, we will show you how to change the default gravatar in WordPress and replace it with your own custom default gravatar image.

是否要在WordPress网站上更改默认的Gravatar? 通过添加您自己的默认图像,您可以将您的评论部分标记为品牌。 在本文中,我们将向您展示如何在WordPress中更改默认的gravatar并将其替换为您自己的自定义默认gravatar图像。

How to change default gravatar image in WordPress
什么是默认Gravatar,为什么要更改它? (What is Default Gravatar and Why Change it?)

Gravatar is a web service created and run by WordPress co-founder Matt Mullenweg’s company called Automattic. It allows anyone to create a profile and associate avatar images to their email addresses.

Gravatar是由WordPress联合创始人Matt Mullenweg的公司Automattic创建和运行的Web服务。 它允许任何人创建配置文件并将头像图像与其电子邮件地址相关联。

This avatar image is then displayed on all WordPress blogs where users leave comments or write blog posts. For more details see our guide on What is gravatar and why you should start using it right away.

然后,此头像图像显示在所有WordPress博客上,用户在其中留下评论或撰写博客文章。 有关更多详细信息,请参见“ 什么是Gravatar”以及为什么立即开始使用它的指南

All WordPress sites come with built-in support for gravatars and automatically show users’ avatars when they write posts or leave comments.

所有WordPress网站都内置了对gravatars的支持,并在用户撰写帖子或发表评论时自动显示用户的头像。

However, if a user doesn’t have a gravatar image, then WordPress automatically shows the default gravatar image. The default option is to show an image called mystery man. It looks like this:

但是,如果用户没有图像,则WordPress会自动显示默认图像。 默认选项是显示一个名为“神秘男子”的图像。 看起来像这样:

Default mystery person gravatar in WordPress

If you don’t want to use the mystery man as default image, then you can change it to your own branded image.

如果您不想将神秘男子用作默认图片,则可以将其更改为自己的品牌图片。

Having said that, let’s see how you can change the default gravatar image on your WordPress site, so you can use a custom default gravatar image.

话虽如此,让我们看看如何在WordPress网站上更改默认的Gravatar图像,以便可以使用自定义的默认Gravatar图像。

在WordPress中更改默认Gravatar图像 (Changing Default Gravatar Image in WordPress)

First, you need to visit Settings » Discussion page and scroll down to Avatars section. This is where you can configure and change gravatar settings on your WordPress site.

首先,您需要访问设置»讨论页面,然后向下滚动到头像部分。 您可以在此处配置和更改WordPress网站上的Gravatar设置。

Gravatar settings in WordPress

You will notice that there are a few choices available under the default avatar option. These avatars are used when a user does not have a gravatar associated with their email address.

您会注意到,默认头像选项下有一些可用选项。 当用户没有与其电子邮件地址关联的头像时,将使用这些头像。

Out of the box WordPress uses the mystery person icon as the default gravatar. You can change that to blank or gravatar logo.

WordPress开箱即用地将神秘人物图标作为默认的图形表达。 您可以将其更改为空白或Gravatar徽标。

There are few other options available as well. These are automatically generated images in different designs. These images use comment author’s name or email address to mathematically generate a unique gravatar image.

其他选项也很少。 这些是在不同设计中自动生成的图像。 这些图像使用评论作者的姓名或电子邮件地址以数学方式生成唯一的图像。

Don’t forget to click on the save changes button after changing your default gravatar.

更改默认头像后,不要忘记单击“保存更改”按钮。

在WordPress中使用自定义默认Gravatar图像 (Using Custom Default Gravatar Image in WordPress)

WordPress also allows you to use your own default gravatar images. Here is how you can easily add your own custom default gravatar image in WordPress.

WordPress还允许您使用自己的默认图像。 这是您可以轻松在WordPress中添加自己的自定义默认图像的方法。

First you need to create an image that you want to use as the default gravatar. This image should be a square, like 250×250 pixels.

首先,您需要创建要用作默认图像的图像。 该图像应为正方形,例如250×250像素。

Next, you need to upload this image to your WordPress site. Head over to Media » Add New and upload your custom default gravatar image.

接下来,您需要将此图像上传到WordPress网站。 转到Media»Add New,然后上传您的自定义默认图像。

Upload and edit custom default gravatar image

After the image is uploaded, you need to click on the Edit link next to the image.

图片上传后,您需要点击图片旁边的“编辑”链接。

WordPress will now open your image for editing. You need to just copy the image file URL and paste it in a plain text editor like Notepad.

WordPress现在将打开您的图像进行编辑。 您只需要复制图像文件URL并将其粘贴到纯文本编辑器(如记事本)中即可。

Copy file URL

Now you need to add some code to your WordPress site. If you haven’t done this before, then please take a look at our guide on how to copy paste code in WordPress.

现在,您需要向WordPress网站添加一些代码。 如果您之前没有做过,请查看我们的指南, 了解如何在WordPress中复制粘贴代码

Add the following code to your theme’s functions.php file or a site-specific plugin.

将以下代码添加到主题的functions.php文件或特定站点的插件中


add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
function wpb_new_gravatar ($avatar_defaults) {
$myavatar = 'http://example.com/wp-content/uploads/2017/01/wpb-default-gravatar.png';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;
}

Don’t forget to replace $myavatar value to the URL of the custom gravatar image you uploaded earlier.

不要忘记将$myavatar值替换$myavatar您先前上传的自定义图像的URL。

You can now visit Settings » Discussion page and you will notice your custom default avatar added to default avatar choices.

现在,您可以访问设置»讨论页面,您会注意到自定义默认头像已添加到默认头像选择中。

Custom default gravatar image

Select your custom default avatar image, and then click on the save changes button.

选择您的自定义默认头像图像,然后单击“保存更改”按钮。

WordPress will now use your image for users who don’t have their gravatar associated with their email addresses.

WordPress现在将为您的图像与电子邮件地址无关的用户使用您的图像。

Custom default avatar image in WordPress

We hope this article helped you learn how to change the default gravatar on WordPress. You may also want to see our guide on how to set custom avatars for users in WordPress.

我们希望本文能帮助您学习如何更改WordPress上的默认Gravatar。 您可能还希望查看我们的指南, 了解如何为WordPress中的用户设置自定义头像

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-change-the-default-gravatar-on-wordpress/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值