Fix #221: image pastes scale to fit, no code box, accurate size, raw serves image
- paste view: image attachments render in a scalable preview (max-height
min(70vh, 720px), object-fit contain) and the code box is omitted;
wrap/copy buttons hidden for image pastes
- SizeHuman/stats summary show the attachment size for file pastes
(row.Content is empty for file pastes, was showing 0 B)
- /raw/{id} on a file paste streams the attachment bytes inline with its
sniffed mime and filename instead of an empty text/plain body
This commit is contained in:
@@ -6,9 +6,9 @@
|
||||
<h1>{{if .Title}}{{.Title}}{{else}}Untitled paste{{end}}</h1>
|
||||
{{if .CustomSlug}}<span class="slug">/{{.CustomSlug}}</span>{{end}}
|
||||
<div class="spacer"></div>
|
||||
<button type="button" class="iconbtn wrap-toggle" title="Toggle line wrap" aria-pressed="false">wrap</button>
|
||||
{{if not .AttachmentIsImage}}<button type="button" class="iconbtn wrap-toggle" title="Toggle line wrap" aria-pressed="false">wrap</button>{{end}}
|
||||
<a class="iconbtn" href="/raw/{{.ID}}">raw</a>
|
||||
<a class="iconbtn" href="#" id="copy-btn">copy</a>
|
||||
{{if not .AttachmentIsImage}}<a class="iconbtn" href="#" id="copy-btn">copy</a>{{end}}
|
||||
{{if .DeletionToken}}<a class="iconbtn danger" href="#" id="delete-btn">delete</a>{{end}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -44,14 +44,19 @@
|
||||
<span class="attachment-size">{{.Attachment.SizeHuman}}</span>
|
||||
</a>
|
||||
{{if or (eq .Attachment.Mime "image/png") (eq .Attachment.Mime "image/jpeg") (eq .Attachment.Mime "image/gif") (eq .Attachment.Mime "image/webp")}}
|
||||
{{/* #221: image pastes scale to fit; no text/code box underneath */}}
|
||||
<div class="attachment-preview is-image"><img src="/f/{{.Attachment.ID}}/{{.Attachment.Filename}}" alt="{{.Attachment.Filename}}"></div>
|
||||
{{else}}
|
||||
<div class="attachment-preview"><img src="/f/{{.Attachment.ID}}/{{.Attachment.Filename}}" alt="{{.Attachment.Filename}}"></div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if not .AttachmentIsImage}}{{/* #221: image pastes replace the code box entirely */}}
|
||||
<div class="float">
|
||||
<div class="code" id="code"><div class="gutter" id="gutter">{{.Gutter}}</div><div class="codebody" id="codebody">{{.ContentHTML}}</div></div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<input type="hidden" id="raw-content" value="{{.ContentAttr}}">
|
||||
<script src="/static/paste.js" defer data-paste-id="{{.ID}}"></script>
|
||||
|
||||
Reference in New Issue
Block a user