制作zblog php模板评论部分时正确调用用户邮箱的gravatar头像的方法

搬瓦工机场JMS

制作zblog php模板评论部分时,需要显示评论用户邮箱的gravatar头像,添加zblog官方给出的评论头像地址调用标签{$comment.Author.Avatar},发现无法正常显示gravatar头像,所有的评论用户统一显示zblog默认头像0.png,模板代码检查无果,VPS全科网选择使用md5加密邮箱地址传递参数的方法实现。

实现原理:

很简单,gravatar头像地址格式是:

https://img.wervps.gedoucheng.com/wervps/qk-20211025/ravatar.com style=”margin-top: 0px; margin-bottom: 20px; padding: 0px; line-height: 2em; color: rgb(51, 51, 51); font-family: tahoma, Arial, "Microsoft Yahei", Simsun; white-space: normal; background-color: rgb(255, 255, 255);”>后面的那一串是Gravatar使用的是MD5加密之后的Email字符串,因此只需要使用MD5把评论用户的邮箱加密成字符串,然后添加到

https://img.wervps.gedoucheng.com/wervps/qk-20211025/ravatar.com style=”margin-top: 0px; margin-bottom: 20px; padding: 0px; line-height: 2em; color: rgb(51, 51, 51); font-family: tahoma, Arial, "Microsoft Yahei", Simsun; white-space: normal; background-color: rgb(255, 255, 255);”>后面即可调用该邮箱gravatar头像。

实现代码:

1
2
3
4
{php}
	$avatar = md5(strtolower($comment->Author->Email));
{/php}<img src="http://cn.gravatar.com/avatar/{$avatar}" alt="{$comment.Author.StaticName}"/>

$comment->Author->Email是评论用户邮箱代码

VPS全科网建议要有耐心仔细检查问题原因所在,使用官方提供的调用标签。

未经允许不得转载:搬瓦工VPS_美国VPS » 制作zblog php模板评论部分时正确调用用户邮箱的gravatar头像的方法

赞 (0) 打赏

相关推荐

    暂无内容!

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏