From b35c1b5784b99fa71d0ea3ddf8ac253dc44c0d82 Mon Sep 17 00:00:00 2001 From: bobemoe Date: Sun, 13 Dec 2020 19:12:27 +0000 Subject: add thumbnail preview section to issue attachments (#13826) * add thumbnail preview section to attachments * dont show thumbnail if the image is already shown inline * update router to pass the `content` to the attachemnts template * limit attachment preview height to 150px (same as width) * remove unused css (referance removed in https://github.com/go-gitea/gitea/pull/11141/files#diff-9faae32445ed9673de2830c9fc35e93f44487f0a0068202988adaf00a5bac850L66 ) * dont show divider after edit if no attachemnts Co-authored-by: James Co-authored-by: 6543 <6543@obermui.de> --- routers/repo/issue.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'routers/repo/issue.go') diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 6ebc5d6ecb..e350f74de9 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -1649,7 +1649,7 @@ func UpdateIssueContent(ctx *context.Context) { ctx.JSON(200, map[string]interface{}{ "content": string(markdown.Render([]byte(issue.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())), - "attachments": attachmentsHTML(ctx, issue.Attachments), + "attachments": attachmentsHTML(ctx, issue.Attachments, issue.Content), }) } @@ -2065,7 +2065,7 @@ func UpdateCommentContent(ctx *context.Context) { ctx.JSON(200, map[string]interface{}{ "content": string(markdown.Render([]byte(comment.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())), - "attachments": attachmentsHTML(ctx, comment.Attachments), + "attachments": attachmentsHTML(ctx, comment.Attachments, comment.Content), }) } @@ -2399,10 +2399,11 @@ func updateAttachments(item interface{}, files []string) error { return err } -func attachmentsHTML(ctx *context.Context, attachments []*models.Attachment) string { +func attachmentsHTML(ctx *context.Context, attachments []*models.Attachment, content string) string { attachHTML, err := ctx.HTMLString(string(tplAttachment), map[string]interface{}{ "ctx": ctx.Data, "Attachments": attachments, + "Content": content, }) if err != nil { ctx.ServerError("attachmentsHTML.HTMLString", err) -- cgit v1.2.3