Fix 'Reveal Spoiler Thumbnails' on .bmp files.

This commit is contained in:
ccd0 2020-06-16 01:23:25 -07:00
parent 510603e8f2
commit 44ca4c34bb
3 changed files with 6 additions and 3 deletions

View File

@ -199,8 +199,8 @@ class Post
$.extend file,
url: file.link.href
isImage: /\.(jpe?g|png|gif|bmp)$/i.test file.link.href
isVideo: /\.(webm|mp4)$/i.test file.link.href
isImage: $.isImage file.link.href
isVideo: $.isVideo file.link.href
size = +file.size.match(/[\d.]+/)[0]
unit = ['B', 'KB', 'MB', 'GB'].indexOf file.size.match(/\w+$/)[0]
size *= 1024 while unit-- > 0

View File

@ -490,6 +490,9 @@ $.unescape = (text) ->
text.replace(/<[^>]*>/g, '').replace /&(amp|#039|quot|lt|gt|#44);/g, (c) ->
(({'&amp;': '&', '&#039;': "'", '&quot;': '"', '&lt;': '<', '&gt;': '>', '&#44;': ','})[c])
$.isImage = (url) -> /\.(jpe?g|png|gif|bmp)$/i.test url
$.isVideo = (url) -> /\.(webm|mp4)$/i.test url
$.engine = do ->
return 'edge' if /Edge\//.test navigator.userAgent
return 'blink' if /Chrome\//.test navigator.userAgent

View File

@ -218,7 +218,7 @@ SW.tinyboard =
dimensions: info[0].match(/\d+x\d+/)?[0]
if thumb
$.extend file,
thumbURL: if /\/static\//.test(thumb.src) and /\.(?:gif|jpe?g|png)$/.test(link.href) then link.href else thumb.src
thumbURL: if /\/static\//.test(thumb.src) and $.isImage(link.href) then link.href else thumb.src
isSpoiler: /^Spoiler/i.test(info[1] or '') or link.textContent is 'Spoiler Image'
true