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,11 +143,14 @@ Upload.toggle_size = function(e) {
Upload.update_scale = function() { Upload.update_scale = function() {
let $image = $("#image"); let $image = $("#image");
if ($image.length) {
let natural_width = $image.get(0).naturalWidth; let natural_width = $image.get(0).naturalWidth;
let natural_height = $image.get(0).naturalHeight; let natural_height = $image.get(0).naturalHeight;
let scale_percentage = Math.round(100 * $image.width() / natural_width); 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-image-metadata-resolution").html(`(${natural_width}x${natural_height}, resized to ${scale_percentage}%)`);
} }
}
Upload.fetch_data_manual = function(e) { Upload.fetch_data_manual = function(e) {
var url = $("#upload_source,#post_source").val(); var url = $("#upload_source,#post_source").val();