uploads: fix js error when resizing window.

Fix exception when resizing the window when the preview image isn't
present.
This commit is contained in:
evazion
2020-08-05 12:27:32 -05:00
parent 1a5cda44b9
commit 56a4e58510

View File

@@ -143,10 +143,13 @@ Upload.toggle_size = function(e) {
Upload.update_scale = function() {
let $image = $("#image");
let natural_width = $image.get(0).naturalWidth;
let natural_height = $image.get(0).naturalHeight;
let scale_percentage = Math.round(100 * $image.width() / natural_width);
$("#upload-image-metadata-resolution").html(`(${natural_width}x${natural_height}, resized to ${scale_percentage}%)`);
if ($image.length) {
let natural_width = $image.get(0).naturalWidth;
let natural_height = $image.get(0).naturalHeight;
let scale_percentage = Math.round(100 * $image.width() / natural_width);
$("#upload-image-metadata-resolution").html(`(${natural_width}x${natural_height}, resized to ${scale_percentage}%)`);
}
}
Upload.fetch_data_manual = function(e) {