找了下typecho的相关文章,并没有找到获取老访客的头像的文章,那就只能自己动手实现了。
typecho获取邮箱地址为:
<?php $this->remember('mail',true) ?>
直接通过URL获取Gravatar头像地址
<img src="http://www.gravatar.com/avatar/md5(<?php $this->remember('mail',true) ?>)?s=32" >;
由于使用了gravatar头像缓存插件GravatarCache,这让头像显示变的简单
因为GravatarCache中实现了根据邮箱获取头像的函数
<?php GravatarCache::getGravatarCache('[email protected]'); ?>
原始效果
使用后效果
实际效果可以参考本站评论!
<?php if($this->remember('author',true) != "" && $this->remember('mail',true) != ""){ ?>
<p class="title welcome" style="text-align:center;">
<a class="edit_author" onclick="$('.welcome').hide()&&$('.author_info').show();return false;">
<img style="display: block;margin: 35px auto 8px auto;float: center;" class="avatar" src="<?php echo GravatarCache::getGravatarCache($this->remember('mail',true),false,50); ?>" alt="QQ" width="50" height="50">
<?php $this->remember('author'); ?>
</a>
</p>
<div class="author_info" style="display:none;">
<?php } ?>
<p>
<label for="author" class="required"><?php _e('称呼'); ?></label>
<input type="text" name="author" id="author" class="text" value="<?php $this->remember('author'); ?>" />
</p>
<p>
<label for="mail"<?php if ($this->options->commentsRequireMail): ?> class="required"<?php endif; ?>><?php _e('邮箱'); ?></label>
<input type="email" name="mail" id="mail" class="text" value="<?php $this->remember('mail'); ?>" />
</p>
<p>
<label for="url"<?php if ($this->options->commentsRequireURL): ?> class="required"<?php endif; ?>><?php _e('网站'); ?></label>
<input type="url" name="url" id="url" class="text" placeholder="<?php _e('http://example.com'); ?>" value="<?php $this->remember('url'); ?>" />
</p>
<?php if($this->remember('author',true) != "" && $this->remember('mail',true) != ""){ ?>
</div>
<?php } ?>