Add some basic sanity checks for width & height == 0

pull/3468/head
Isaac Connor 2022-04-07 19:38:43 -04:00
parent a58111fa46
commit 37d0b6e606
1 changed files with 9 additions and 4 deletions

View File

@ -170,12 +170,17 @@ function changeScale() {
// This is so that we don't waste bandwidth and let the browser do all the scaling.
if (autoScale > 100) autoScale = 100;
if (scale > 100) scale = 100;
if (autoScale <= 0) autoScale = 100;
const newSrc = oldSrc.replace(/scale=\d+/i, 'scale='+((scale == 'auto' || scale == '0') ? autoScale : scale));
streamImg.css('width', newWidth+'px');
streamImg.width(newWidth);
streamImg.css('height', newHeight+'px');
streamImg.height(newHeight);
if (parseInt(newWidth) > 0) {
streamImg.css('width', newWidth+'px');
streamImg.width(newWidth);
}
if (parseInt(newHeight) > 0) {
streamImg.css('height', newHeight+'px');
streamImg.height(newHeight);
}
streamImg.attr('src', newSrc);
} else {
console.log("Not an IMG, can't set size");