mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 23:15:49 +01:00
(refs #33)Improve avatar image searching behavior.
This commit is contained in:
@@ -13,17 +13,31 @@ trait AvatarImageProvider { self: RequestCache =>
|
|||||||
protected def getAvatarImageHtml(userName: String, size: Int,
|
protected def getAvatarImageHtml(userName: String, size: Int,
|
||||||
mailAddress: String = "", tooltip: Boolean = false)(implicit context: app.Context): Html = {
|
mailAddress: String = "", tooltip: Boolean = false)(implicit context: app.Context): Html = {
|
||||||
|
|
||||||
val src = getAccountByUserName(userName).map { account =>
|
val src = if(mailAddress.isEmpty){
|
||||||
if(account.image.isEmpty && getSystemSettings().gravatar){
|
// by user name
|
||||||
s"""http://www.gravatar.com/avatar/${StringUtil.md5(account.mailAddress)}?s=${size}"""
|
getAccountByUserName(userName).map { account =>
|
||||||
} else {
|
if(account.image.isEmpty && getSystemSettings().gravatar){
|
||||||
s"""${context.path}/${userName}/_avatar"""
|
s"""http://www.gravatar.com/avatar/${StringUtil.md5(account.mailAddress)}?s=${size}"""
|
||||||
|
} else {
|
||||||
|
s"""${context.path}/${account.userName}/_avatar"""
|
||||||
|
}
|
||||||
|
} getOrElse {
|
||||||
|
s"""${context.path}/_unknown/_avatar"""
|
||||||
}
|
}
|
||||||
} getOrElse {
|
} else {
|
||||||
if(mailAddress.nonEmpty && getSystemSettings().gravatar){
|
// by mail address
|
||||||
s"""http://www.gravatar.com/avatar/${StringUtil.md5(mailAddress)}?s=${size}"""
|
getAccountByMailAddress(mailAddress).map { account =>
|
||||||
} else {
|
if(account.image.isEmpty && getSystemSettings().gravatar){
|
||||||
s"""${context.path}/${userName}/_avatar"""
|
s"""http://www.gravatar.com/avatar/${StringUtil.md5(account.mailAddress)}?s=${size}"""
|
||||||
|
} else {
|
||||||
|
s"""${context.path}/${account.userName}/_avatar"""
|
||||||
|
}
|
||||||
|
} getOrElse {
|
||||||
|
if(mailAddress.nonEmpty && getSystemSettings().gravatar){
|
||||||
|
s"""http://www.gravatar.com/avatar/${StringUtil.md5(mailAddress)}?s=${size}"""
|
||||||
|
} else {
|
||||||
|
s"""${context.path}/_unknown/_avatar"""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user