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> --- templates/repo/issue/view_content.tmpl | 11 ++--- templates/repo/issue/view_content/attachments.tmpl | 55 ++++++++++++++++------ templates/repo/issue/view_content/comments.tmpl | 11 ++--- 3 files changed, 47 insertions(+), 30 deletions(-) (limited to 'templates/repo') diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 355ba0ea29..37628a74e8 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -66,14 +66,9 @@
{{.Issue.Content}}
- {{if .Issue.Attachments}} -
-
-
- {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Issue.Attachments}} -
-
- {{end}} + {{if .Issue.Attachments}} + {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Issue.Attachments "Content" .Issue.RenderedContent}} + {{end}} {{$reactions := .Issue.Reactions.GroupByType}} {{if $reactions}} diff --git a/templates/repo/issue/view_content/attachments.tmpl b/templates/repo/issue/view_content/attachments.tmpl index d76c0bbfa2..16d77847d0 100644 --- a/templates/repo/issue/view_content/attachments.tmpl +++ b/templates/repo/issue/view_content/attachments.tmpl @@ -1,15 +1,42 @@ -{{- range .Attachments -}} -
- - {{if FilenameIsImage .Name}} - {{svg "octicon-file"}} - {{else}} - {{svg "octicon-desktop-download"}} - {{end}} - {{.Name}} - +
+ {{if .Attachments}} +
+ {{end}} + + + {{if $hasThumbnails}} +
+
+ {{- range .Attachments -}} + {{if FilenameIsImage .Name}} + {{if not (containGeneric $.Content .UUID)}} + + + + {{end}} + {{end}} + {{end -}} +
+ {{end}} +
-
- {{.Size | FileSize}} -
-{{end -}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 698e4698d0..2c413b3c46 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -72,14 +72,9 @@
{{.Content}}
- {{if .Attachments}} -
-
-
- {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments}} -
-
- {{end}} + {{if .Attachments}} + {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments "Content" .RenderedContent}} + {{end}} {{$reactions := .Reactions.GroupByType}} {{if $reactions}} -- cgit v1.2.3