parweb-filepond-plugin-image-resize
Version:
Image Resize Plugin for FilePond
6 lines • 1.09 kB
JavaScript
/*
* FilePondPluginImageResize 1.0.0
* Licensed under MIT, https://opensource.org/licenses/MIT
* Please visit https://pqina.nl/filepond for details.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.FilePondPluginImageResize=t()}(this,function(){"use strict";var e=function(e){return/^image/.test(e.type)},t=function(t){var i=t.addFilter,n=t.utils,o=n.Type;return i("DID_LOAD_ITEM",function(t,i){var n=i.query;return new Promise(function(i,o){var u=t.file;if(!e(u)||!n("GET_ALLOW_IMAGE_RESIZE"))return i(t);var r=n("GET_IMAGE_RESIZE_MODE"),E=n("GET_IMAGE_RESIZE_TARGET_WIDTH"),d=n("GET_IMAGE_RESIZE_TARGET_HEIGHT");return null===E&&null===d?i(t):(t.setMetadata("resize",{mode:r,size:{width:E,height:d}}),i(t))})}),{options:{allowImageResize:[!0,o.BOOLEAN],imageResizeMode:["cover",o.STRING],imageResizeTargetWidth:[null,o.INT],imageResizeTargetHeight:[null,o.INT]}}};return "undefined"!=typeof navigator&&document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:t})),t});