The createFilePondExtensionSet function creates an array of default extensions. These extensions are used by the <file-pond> element and are loaded in the the following order.
-
FileInputSourceis used to load files from the file input inside thefile-pondcustom element. -
DataTransferLoaderis used to load files inside datatransfers dropped on FilePond. -
FileExtensionValidatoris used to validate file extensions -
FileMimeTypeValidatoris used to validate file mime types -
ValueCallbackStoreis used to link up the FilePond elementvalueproperty with the internal state. -
EntryListViewrenders the file list view.
When we set additional extensions using defineFilePond they’re automatically passed to createFilePondExtensionSet and added to the default extension list.
Extensions will be inserted after extensions of the same time. CanvasLoader will be inserted after the default DataTransferLoader, FormPostStore will be inserted after the ValueCallbackStore.
const extensions = createFilePondExtensionSet([CanvasLoader, BlobLoader, FormPostStore]);
console.log(extensions);
// Logs:
// - FileInputSource
// - DataTransferLoader
// - CanvasLoader <-
// - BlobLoader <-
// - FileExtensionValidator
// - FileMimeTypeValidator
// - ValueCallbackStore
// - FormPostStore <-
// - EntryListView
A transform extension will be inserted after validator extensions and before store extensions.
Should we want to apply a transform before validating a file we can choose where to insert the extension by passing an additional configuration object { before: 'ExtensionName' }, or { after: 'ExtensionName' }.
const extensions = createFilePondExtensionSet([
[
MediaResolutionValidator,
{
maxWidth: 500,
},
],
[
// Extension function
ImageBitmapTransform,
// Extension configuration
{
width: 500,
},
// Insertion instructions
{
before: 'MediaResolutionValidator',
},
],
]);
console.log(extensions);
// Logs:
// - FileInputSource
// - DataTransferLoader
// - FileExtensionValidator
// - FileMimeTypeValidator
// - ImageBitmapTransform <-
// - MediaResolutionValidator <-
// - ValueCallbackStore
// - EntryListView