medium-editor-insert-plugin
medium-editor-insert-plugin copied to clipboard
image resize before upload does not work
Hi there,
as this plugin uses blueimp fileupload for uplading images I though I could just add this to fileUploadOptions
:
disableImageResize: false,
imageMaxWidth: 400,
imageMaxHeight: 400
(Of course I added the depending js libs to my app) Unfortunately that does not work at all. The file is uploaded but not resized before. Are there maybe some interfering things with the preview function of this plugin and the blueimp process() ?
Thanks
No, client size resizing is not supported right now. The only option is to resize on server and return to the plugin resized imaged.
Well, you use blueimp fileupload which supports resizing. So it should only be some little piece of code to make it work. If you give me a hint why it doesn't work out of the box I can do it.
I don't know how blueimp's resizing works. In our plugin we use Images.showImage(img, data)
function to add an image to content.
This function is called twice:
- If you have
preview
enabled, it is called fromImages.uploadAdd()
function withimg
parameter set to preview image data BLOB. - When upload is done, the function is called one more time from
Images.uploadDone()
function where it is called withimg
parameter set to URL to uploaded image and if thepreview
was enabled, the preview image is just replaced with the real image URL.
So my guess would be to take a look at Images.uploadDone()
and change data.result.files[0].url
to resized image provided by jQuery File Upload plugin.
I have found a solution as below with changing "medium-editor-insert-plugin.js"
fileUploadOptions = {
dataType: 'json',
add: function (e, data) {
$.proxy(that, 'uploadAdd', e, data)();
$.blueimp.fileupload.prototype.options.add.call(this, e, data); // Add this line
},
done: function (e, data) {
$.proxy(that, 'uploadDone', e, data)();
},
disableImageResize: false, // Add this line
imageMaxWidth: 960, // Add this line
};