Mnews主题自从1.2版本后,作者剔除了评论者获取Gravatar头像代码,而自己网站目前暂未开放注册,故评论者都是非注册id,奈何头像显示问题一直困扰着我,经过3天研究,终于搞定了!!!
comment-ajax.php
本人使用的是Mnews1.9版本,代码位置可能有所不一致,自己Ctrl+F查找,大概在文本第19行:
- <?php $user_id = $comment->user_id; $user_name = $comment->comment_author; echo salong_get_avatar($user_id,$user_name); ?>
把user_id改为comment_author_email,salong_get_avatar改为get_avatar,完整代码如下:
- <?php $user_id = $comment->comment_author_email; $user_name = $comment->comment_author; echo get_avatar($user_id,$user_name); ?>
salong-functions.php
大概1012行替换以下代码:
- $avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','<img src="https://secure.gravatar.com/avatar/$1?s=32" class="avatar avatar-32" height="32" width="32">',$avatar);
替换成:
- $avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','<img src="http://cn.gravatar.com/avatar/$1?s=$2&d=mm" alt="avatar" class="avatar avatar-$2" height="$2" width="$2">',$avatar);
效果演示
其他位置补充
把以下PHP代码中的salong_get_avatar替换成get_avatar,某些文件有$comment->user_id的替换成$comment->comment_author_email即可,代码都是同一行,貌似只有widget-comments.php文件需要替换$comment->user_id
\author.php,大概第19行
\content\author-comment.php,大概32行
\content\info-post.php,大概20行
\includes\widgets\widget-comments.php,大概在32行
还有很多我就不一一列举了,看图:
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。