diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index cfcde66b5..9d75dfe1b 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -5988,12 +5988,46 @@ QR.cleanNotifications(); for (_i = 0, _len = files.length; _i < _len; _i++) { file = files[_i]; - QR.handleFile(file, isSingle, max); + QR.checkDimensions(file, isSingle, max); } if (!isSingle) { return $.addClass(QR.nodes.el, 'dump'); } }, + 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 (g.BOARD.ID === 'hr') { + if (height > 10000 || width > 10000) { + return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: 10000x10000px"); + } + } + if (g.BOARD.ID === 'hr') { + if (height < 1000 || width < 1000) { + return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: 1000x1000px"); + } + } + if (g.BOARD.ID === 'wg') { + if (height < 480 || width < 600) { + return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: 480x600px"); + } + } + if (g.BOARD.ID === 'w') { + if (height < 480 || width < 600) { + return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: 480x600px"); + } + } + if (height > 5000 || width > 5000) { + return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: 5000x5000px"); + } + return QR.handleFile(file, isSingle, max); + }; + return img.src = URL.createObjectURL(file); + }, handleFile: function(file, isSingle, max) { var post, _ref; if (file.size > max) { diff --git a/builds/crx/script.js b/builds/crx/script.js index b87014ea9..8a90ea2a1 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -6024,12 +6024,46 @@ QR.cleanNotifications(); for (_i = 0, _len = files.length; _i < _len; _i++) { file = files[_i]; - QR.handleFile(file, isSingle, max); + QR.checkDimensions(file, isSingle, max); } if (!isSingle) { return $.addClass(QR.nodes.el, 'dump'); } }, + 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 (g.BOARD.ID === 'hr') { + if (height > 10000 || width > 10000) { + return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: 10000x10000px"); + } + } + if (g.BOARD.ID === 'hr') { + if (height < 1000 || width < 1000) { + return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: 1000x1000px"); + } + } + if (g.BOARD.ID === 'wg') { + if (height < 480 || width < 600) { + return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: 480x600px"); + } + } + if (g.BOARD.ID === 'w') { + if (height < 480 || width < 600) { + return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: 480x600px"); + } + } + if (height > 5000 || width > 5000) { + return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: 5000x5000px"); + } + return QR.handleFile(file, isSingle, max); + }; + return img.src = URL.createObjectURL(file); + }, handleFile: function(file, isSingle, max) { var post, _ref; if (file.size > max) { diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 18b8c806d..5bfca34a4 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -355,9 +355,25 @@ QR = isSingle = files.length is 1 QR.cleanNotifications() for file in files - QR.handleFile file, isSingle, max + QR.checkDimensions file, isSingle, max $.addClass QR.nodes.el, 'dump' unless isSingle + checkDimensions: (file, isSingle, max) -> + img = new Image() + img.onload = => + {height, width} = img + if g.BOARD.ID is 'hr' + return QR.error "#{file.name}: Image too large (image: #{img.height}x#{img.width}px, max: 10000x10000px" if height > 10000 or width > 10000 + if g.BOARD.ID is 'hr' + return QR.error "#{file.name}: Image too small (image: #{img.height}x#{img.width}px, min: 1000x1000px" if height < 1000 or width < 1000 + if g.BOARD.ID is 'wg' + return QR.error "#{file.name}: Image too small (image: #{img.height}x#{img.width}px, min: 480x600px" if height < 480 or width < 600 + if g.BOARD.ID is 'w' + return QR.error "#{file.name}: Image too small (image: #{img.height}x#{img.width}px, min: 480x600px" if height < 480 or width < 600 + return QR.error "#{file.name}: Image too large (image: #{img.height}x#{img.width}px, max: 5000x5000px" if height > 5000 or width > 5000 + QR.handleFile file, isSingle, max + img.src = URL.createObjectURL file + handleFile: (file, isSingle, max) -> if file.size > max QR.error "#{file.name}: File too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString max})."