Show error if image is greater than max prefetch size

This commit is contained in:
Al McKinlay 2017-12-28 16:28:49 +00:00 committed by Jérémie Astori
parent 6b024191c1
commit 335bd803af
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8
2 changed files with 12 additions and 4 deletions

View File

@ -28,5 +28,11 @@
<div class="body" title="{{body}}">{{body}}</div> <div class="body" title="{{body}}">{{body}}</div>
</a> </a>
{{/equal}} {{/equal}}
{{#equal type "error"}}
<a class="toggle-text" href="{{link}}" target="_blank" rel="noopener">
<div class="head" title="{{head}}">{{head}}</div>
<div class="body" title="{{body}}">{{body}}</div>
</a>
{{/equal}}
</div> </div>
{{/preview}} {{/preview}}

View File

@ -99,11 +99,13 @@ function parse(msg, preview, res, client) {
case "image/jpeg": case "image/jpeg":
case "image/webp": case "image/webp":
if (res.size > (Helper.config.prefetchMaxImageSize * 1024)) { if (res.size > (Helper.config.prefetchMaxImageSize * 1024)) {
return; preview.type = "error";
} preview.head = "Large image";
preview.body = "Image is greater than your max image size. Click to view.";
} else {
preview.type = "image"; preview.type = "image";
preview.thumb = preview.link; preview.thumb = preview.link;
}
break; break;