Handle both WebP and original avatars
This commit is contained in:
26
main.go
26
main.go
@ -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
|
||||
|
Reference in New Issue
Block a user