1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

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 <inbox.dev@jhodges.co.uk>
Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
bobemoe
2020-12-13 19:12:27 +00:00
committed by GitHub
parent 825efa2605
commit b35c1b5784
6 changed files with 56 additions and 81 deletions

View File

@@ -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)