Added imagekit optimization support
This commit is contained in:
@@ -53,6 +53,8 @@ func (ps *AdminDashboardHandler) RejectMedia(c *gin.Context) {
|
||||
|
||||
func (ps *AdminDashboardHandler) GetMedia(c *gin.Context) {
|
||||
media := ps.PostService.GetMedia()
|
||||
media.PreviewUrl = services.GetPreviewUrl(media.PreviewUrl)
|
||||
media.RemoteUrl = services.GetPreviewUrl(media.RemoteUrl)
|
||||
c.JSON(http.StatusOK, media)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,14 @@ func InitApiEndpointHandler() {
|
||||
ApiEndpointHandlerInstance = &ApiEndpointHandler{
|
||||
PostService: *services.PostServiceInstance,
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
func (ps *ApiEndpointHandler) GetRandomPost(c *gin.Context) {
|
||||
c.JSON(200,ps.PostService.GetRandomPost())
|
||||
}
|
||||
post := ps.PostService.GetRandomPost()
|
||||
for _, attachment := range post.Attachments {
|
||||
attachment.RemoteUrl = services.GetRemoteUrl(attachment.RemoteUrl)
|
||||
attachment.PreviewUrl = services.GetPreviewUrl(attachment.RemoteUrl)
|
||||
}
|
||||
c.JSON(200, post)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,6 @@ func (ps *EmbedCardHandler) GetEmbedCard(c *gin.Context) {
|
||||
post := ps.PostService.GetRandomPost()
|
||||
c.HTML(200, "home/embed.html", gin.H{
|
||||
"postUrl": post.Url,
|
||||
"imageUrl": post.Attachments[0].RemoteUrl,
|
||||
"imageUrl": services.GetRemoteUrl(post.Attachments[0].RemoteUrl),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user