diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 1741399b4..12d007e1a 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -5586,7 +5586,7 @@ }; 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() { var sc; if (!Conf['Quick Reply']) { @@ -6003,19 +6003,23 @@ checkDimensions: function(file, isSingle, max) { var img, _this = this; - img = new Image(); - img.onload = function() { - var height, width; - height = img.height, width = img.width; - if (height > QR.max_heigth || width > QR.max_heigth) { - return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: " + QR.max_heigth + "x" + QR.max_width + "px)"); - } - if (height < QR.min_heigth || 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 (/^image\//.test(file.type)) { + img = new Image(); + img.onload = function() { + var height, width; + height = img.height, width = img.width; + if (height > QR.max_heigth || width > QR.max_heigth) { + return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: " + QR.max_heigth + "x" + QR.max_width + "px)"); + } + if (height < QR.min_heigth || 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)"); + } + return QR.handleFile(file, isSingle, max); + }; + return img.src = URL.createObjectURL(file); + } else { return QR.handleFile(file, isSingle, max); - }; - return img.src = URL.createObjectURL(file); + } }, handleFile: function(file, isSingle, max) { var post, _ref; @@ -6978,7 +6982,7 @@ return; } 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'; } return this.updateFilename(); diff --git a/builds/crx/script.js b/builds/crx/script.js index b0eaebc50..6c6512288 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -5620,7 +5620,7 @@ }; 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() { var sc; if (!Conf['Quick Reply']) { @@ -6039,19 +6039,23 @@ checkDimensions: function(file, isSingle, max) { var img, _this = this; - img = new Image(); - img.onload = function() { - var height, width; - height = img.height, width = img.width; - if (height > QR.max_heigth || width > QR.max_heigth) { - return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: " + QR.max_heigth + "x" + QR.max_width + "px)"); - } - if (height < QR.min_heigth || 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 (/^image\//.test(file.type)) { + img = new Image(); + img.onload = function() { + var height, width; + height = img.height, width = img.width; + if (height > QR.max_heigth || width > QR.max_heigth) { + return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: " + QR.max_heigth + "x" + QR.max_width + "px)"); + } + if (height < QR.min_heigth || 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)"); + } + return QR.handleFile(file, isSingle, max); + }; + return img.src = URL.createObjectURL(file); + } else { return QR.handleFile(file, isSingle, max); - }; - return img.src = URL.createObjectURL(file); + } }, handleFile: function(file, isSingle, max) { var post, _ref; @@ -6997,7 +7001,7 @@ return; } 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'; } return this.updateFilename(); diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 593529a3d..1d3943c8f 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -1,5 +1,5 @@ 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: -> return if !Conf['Quick Reply'] @@ -359,13 +359,16 @@ QR = $.addClass QR.nodes.el, 'dump' unless isSingle checkDimensions: (file, isSingle, max) -> - img = new Image() - img.onload = => - {height, width} = img - return QR.error "#{file.name}: Image too large (image: #{img.height}x#{img.width}px, max: #{QR.max_heigth}x#{QR.max_width}px)" if height > QR.max_heigth or width > QR.max_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 + if /^image\//.test file.type + img = new Image() + img.onload = => + {height, width} = img + return QR.error "#{file.name}: Image too large (image: #{img.height}x#{img.width}px, max: #{QR.max_heigth}x#{QR.max_width}px)" if height > QR.max_heigth or width > QR.max_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 + img.src = URL.createObjectURL file + else QR.handleFile file, isSingle, max - img.src = URL.createObjectURL file handleFile: (file, isSingle, max) -> if file.size > max diff --git a/src/Posting/QR.post.coffee b/src/Posting/QR.post.coffee index c11bab53e..c2d530381 100644 --- a/src/Posting/QR.post.coffee +++ b/src/Posting/QR.post.coffee @@ -142,7 +142,7 @@ QR.post = class when 'filename' return unless @file @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, # but it will always replace the extension by the correct one, # so we suffix it with '.jpg' when needed.