add WebM to supported posting types, bypass width/height check for now

This commit is contained in:
ccd0 2014-04-04 15:30:21 -07:00
parent 26576b4420
commit 9ca9360ffd
4 changed files with 47 additions and 36 deletions

View File

@ -5586,7 +5586,7 @@
}; };
QR = { QR = {
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/x-shockwave-flash', ''], mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/x-shockwave-flash', 'video/webm', ''],
init: function() { init: function() {
var sc; var sc;
if (!Conf['Quick Reply']) { if (!Conf['Quick Reply']) {
@ -6003,6 +6003,7 @@
checkDimensions: function(file, isSingle, max) { checkDimensions: function(file, isSingle, max) {
var img, var img,
_this = this; _this = this;
if (/^image\//.test(file.type)) {
img = new Image(); img = new Image();
img.onload = function() { img.onload = function() {
var height, width; var height, width;
@ -6016,6 +6017,9 @@
return QR.handleFile(file, isSingle, max); return QR.handleFile(file, isSingle, max);
}; };
return img.src = URL.createObjectURL(file); return img.src = URL.createObjectURL(file);
} else {
return QR.handleFile(file, isSingle, max);
}
}, },
handleFile: function(file, isSingle, max) { handleFile: function(file, isSingle, max) {
var post, _ref; var post, _ref;
@ -6978,7 +6982,7 @@
return; return;
} }
this.file.newName = this.filename.replace(/[/\\]/g, '-'); this.file.newName = this.filename.replace(/[/\\]/g, '-');
if (!/\.(jpe?g|png|gif|pdf|swf)$/i.test(this.filename)) { if (!/\.(jpe?g|png|gif|pdf|swf|webm)$/i.test(this.filename)) {
this.file.newName += '.jpg'; this.file.newName += '.jpg';
} }
return this.updateFilename(); return this.updateFilename();

View File

@ -5620,7 +5620,7 @@
}; };
QR = { QR = {
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/x-shockwave-flash', ''], mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/x-shockwave-flash', 'video/webm', ''],
init: function() { init: function() {
var sc; var sc;
if (!Conf['Quick Reply']) { if (!Conf['Quick Reply']) {
@ -6039,6 +6039,7 @@
checkDimensions: function(file, isSingle, max) { checkDimensions: function(file, isSingle, max) {
var img, var img,
_this = this; _this = this;
if (/^image\//.test(file.type)) {
img = new Image(); img = new Image();
img.onload = function() { img.onload = function() {
var height, width; var height, width;
@ -6052,6 +6053,9 @@
return QR.handleFile(file, isSingle, max); return QR.handleFile(file, isSingle, max);
}; };
return img.src = URL.createObjectURL(file); return img.src = URL.createObjectURL(file);
} else {
return QR.handleFile(file, isSingle, max);
}
}, },
handleFile: function(file, isSingle, max) { handleFile: function(file, isSingle, max) {
var post, _ref; var post, _ref;
@ -6997,7 +7001,7 @@
return; return;
} }
this.file.newName = this.filename.replace(/[/\\]/g, '-'); this.file.newName = this.filename.replace(/[/\\]/g, '-');
if (!/\.(jpe?g|png|gif|pdf|swf)$/i.test(this.filename)) { if (!/\.(jpe?g|png|gif|pdf|swf|webm)$/i.test(this.filename)) {
this.file.newName += '.jpg'; this.file.newName += '.jpg';
} }
return this.updateFilename(); return this.updateFilename();

View File

@ -1,5 +1,5 @@
QR = QR =
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/x-shockwave-flash', ''] mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/x-shockwave-flash', 'video/webm', '']
init: -> init: ->
return if !Conf['Quick Reply'] return if !Conf['Quick Reply']
@ -359,6 +359,7 @@ QR =
$.addClass QR.nodes.el, 'dump' unless isSingle $.addClass QR.nodes.el, 'dump' unless isSingle
checkDimensions: (file, isSingle, max) -> checkDimensions: (file, isSingle, max) ->
if /^image\//.test file.type
img = new Image() img = new Image()
img.onload = => img.onload = =>
{height, width} = img {height, width} = img
@ -366,6 +367,8 @@ QR =
return QR.error "#{file.name}: Image too small (image: #{img.height}x#{img.width}px, min: #{QR.min_heigth}x#{QR.min_width}px)" if height < QR.min_heigth or width < QR.min_heigth return QR.error "#{file.name}: Image too small (image: #{img.height}x#{img.width}px, min: #{QR.min_heigth}x#{QR.min_width}px)" if height < QR.min_heigth or width < QR.min_heigth
QR.handleFile file, isSingle, max QR.handleFile file, isSingle, max
img.src = URL.createObjectURL file img.src = URL.createObjectURL file
else
QR.handleFile file, isSingle, max
handleFile: (file, isSingle, max) -> handleFile: (file, isSingle, max) ->
if file.size > max if file.size > max

View File

@ -142,7 +142,7 @@ QR.post = class
when 'filename' when 'filename'
return unless @file return unless @file
@file.newName = @filename.replace /[/\\]/g, '-' @file.newName = @filename.replace /[/\\]/g, '-'
unless /\.(jpe?g|png|gif|pdf|swf)$/i.test @filename unless /\.(jpe?g|png|gif|pdf|swf|webm)$/i.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.