简体   繁体   中英

jquery file upload not resizing images client side when using send

I'm using jquery file upload in conjunction with summernote to upload images. I know jquery file-upload is supposed to re size large images to a max of 1920 x 1080 as a default but this isn't happening in my case. Here's my current setup:

 $('#summernote').summernote({
    height: 500,
    minHeight: 300,
    onImageUpload: function(files, editor, welEditable) {
        uploadFile(files, editor, welEditable);
    }
});

$('#fileupload').fileupload({
    url: site_root + '/photos/index.php',
    dataType: 'json',
    acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
    maxFileSize: 8000000,
    imageMaxWidth: 1920,
    imageMaxHeight: 1080,
    imageCrop: true 
});

function uploadFile(files, editor, welEditable) {

    if (files == null) {
        return;
    }

    $('#fileupload').fileupload('send', {files: files})
        .success(function (result, textStatus, jqXHR) {
            //
        });
    });
}

I've even added image maxWidth/Height params but the images fail to be re sized. The image sizing works when I use jquery file upload in other areas but when using the send call it fails to resize them.

Is this a bug or am I missing something obvious?

Thanks, -Paul

Are you including the extra required JS files listed on here?

https://github.com/blueimp/jQuery-File-Upload/wiki/Client-side-Image-Resizing

If so, it looks like you need to set "disableImageResize: false"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM