Handle both WebP and original avatars
This commit is contained in:
parent
e07a865d9c
commit
688c09760b
26
main.go
26
main.go
@ -92,8 +92,17 @@ func main() {
|
|||||||
return ctx.File("images/avatars/large/webp/" + user.ID + ".webp")
|
return ctx.File("images/avatars/large/webp/" + user.ID + ".webp")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = errors.New("Your browser doesn't support the WebP image format")
|
original := arn.FindFileWithExtension(
|
||||||
return ctx.Error(http.StatusBadRequest, err.Error(), err)
|
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
|
// Avatars
|
||||||
@ -109,8 +118,17 @@ func main() {
|
|||||||
return ctx.File("images/avatars/small/webp/" + user.ID + ".webp")
|
return ctx.File("images/avatars/small/webp/" + user.ID + ".webp")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = errors.New("Your browser doesn't support the WebP image format")
|
original := arn.FindFileWithExtension(
|
||||||
return ctx.Error(http.StatusBadRequest, err.Error(), err)
|
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
|
// Elements
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
height avatar-size
|
height avatar-size
|
||||||
border-radius 100%
|
border-radius 100%
|
||||||
object-fit cover
|
object-fit cover
|
||||||
|
opacity 0
|
||||||
default-transition
|
default-transition
|
||||||
:hover
|
:hover
|
||||||
box-shadow outline-shadow-heavy
|
box-shadow outline-shadow-heavy
|
Loading…
Reference in New Issue
Block a user