Randomize Filename: Keep original extension as it will be overwritten anyway.
This commit is contained in:
parent
b829bde742
commit
d8f001c2c9
@ -1,6 +1,8 @@
|
|||||||
QR =
|
QR =
|
||||||
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm']
|
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm']
|
||||||
|
|
||||||
|
validExtension: /\.(jpe?g|png|gif|pdf|swf|webm)$/i
|
||||||
|
|
||||||
typeFromExtension:
|
typeFromExtension:
|
||||||
'jpg': 'image/jpeg'
|
'jpg': 'image/jpeg'
|
||||||
'jpeg': 'image/jpeg'
|
'jpeg': 'image/jpeg'
|
||||||
@ -10,15 +12,6 @@ QR =
|
|||||||
'swf': 'application/vnd.adobe.flash.movie'
|
'swf': 'application/vnd.adobe.flash.movie'
|
||||||
'webm': 'video/webm'
|
'webm': 'video/webm'
|
||||||
|
|
||||||
extensionFromType:
|
|
||||||
'image/jpeg': 'jpg'
|
|
||||||
'image/png': 'png'
|
|
||||||
'image/gif': 'gif'
|
|
||||||
'application/pdf': 'pdf'
|
|
||||||
'application/vnd.adobe.flash.movie': 'swf'
|
|
||||||
'application/x-shockwave-flash': 'swf'
|
|
||||||
'video/webm': 'webm'
|
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
return unless Conf['Quick Reply']
|
return unless Conf['Quick Reply']
|
||||||
|
|
||||||
|
|||||||
@ -179,10 +179,11 @@ QR.post = class
|
|||||||
return
|
return
|
||||||
|
|
||||||
setFile: (@file) ->
|
setFile: (@file) ->
|
||||||
@filename = if Conf['Randomize Filename'] and g.BOARD.ID isnt 'f'
|
if Conf['Randomize Filename'] and g.BOARD.ID isnt 'f'
|
||||||
"#{Date.now() - Math.floor(Math.random() * 365 * $.DAY)}.#{QR.extensionFromType[@file.type] or 'jpg'}"
|
@filename = "#{Date.now() - Math.floor(Math.random() * 365 * $.DAY)}"
|
||||||
|
@filename += ext[0] if ext = @file.name.match QR.validExtension
|
||||||
else
|
else
|
||||||
@file.name
|
@filename = @file.name
|
||||||
@filesize = $.bytesToString @file.size
|
@filesize = $.bytesToString @file.size
|
||||||
@checkSize()
|
@checkSize()
|
||||||
@nodes.label.hidden = false if QR.spoiler
|
@nodes.label.hidden = false if QR.spoiler
|
||||||
@ -299,7 +300,7 @@ QR.post = class
|
|||||||
|
|
||||||
saveFilename: ->
|
saveFilename: ->
|
||||||
@file.newName = (@filename or '').replace /[/\\]/g, '-'
|
@file.newName = (@filename or '').replace /[/\\]/g, '-'
|
||||||
unless /\.(jpe?g|png|gif|pdf|swf|webm)$/i.test @filename
|
unless QR.validExtension.test @filename
|
||||||
# 4chan will truncate the filename if it has no extension,
|
# 4chan will truncate the filename if it has no extension,
|
||||||
# but it will always replace the extension by the correct one,
|
# but it will always replace the extension by the correct one,
|
||||||
# so we suffix it with '.jpg' when needed.
|
# so we suffix it with '.jpg' when needed.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user