Handle both WebP and original avatars

This commit is contained in:
Eduard Urbach 2017-06-13 15:08:10 +02:00
parent e07a865d9c
commit 688c09760b
2 changed files with 23 additions and 4 deletions

26
main.go
View File

@ -92,8 +92,17 @@ func main() {
return ctx.File("images/avatars/large/webp/" + user.ID + ".webp")
}
err = errors.New("Your browser doesn't support the WebP image format")
return ctx.Error(http.StatusBadRequest, err.Error(), err)
original := arn.FindFileWithExtension(
user.ID,
"images/avatars/large/original/",
arn.OriginalImageExtensions,
)
if original == "" {
return ctx.Error(http.StatusNotFound, "Avatar not found", errors.New("Image not found for user: "+user.ID))
}
return ctx.File(original)
})
// Avatars
@ -109,8 +118,17 @@ func main() {
return ctx.File("images/avatars/small/webp/" + user.ID + ".webp")
}
err = errors.New("Your browser doesn't support the WebP image format")
return ctx.Error(http.StatusBadRequest, err.Error(), err)
original := arn.FindFileWithExtension(
user.ID,
"images/avatars/small/original/",
arn.OriginalImageExtensions,
)
if original == "" {
return ctx.Error(http.StatusNotFound, "Avatar not found", errors.New("Image not found for user: "+user.ID))
}
return ctx.File(original)
})
// Elements

View File

@ -4,6 +4,7 @@
height avatar-size
border-radius 100%
object-fit cover
opacity 0
default-transition
:hover
box-shadow outline-shadow-heavy