File upload
The file upload widget uses the Uppy JS uploader. Only one instance per page is allowed at the moment as each instance requires the JS code to target each container ID specifically.
There are various options to customise the how the uploader works, three of which are currently exposed though data-* attributes, controlling whether uploads are automatically initiated or by user interaction; which plugin is used to upload the file(s) - options are TUS and XHRUpload; and which endpoint URL is the target. Details are shown below.
Attributes
data-auto-upload="true|false"- Choose whether to allow automatic or user-initiated uploads - the default is 'false'data-protocol="tus|xhr"- Choose which request protocol to use - the default is 'xhr' (XmlHttpRequest)data-endpoint="YOUR_ENDPOINT_URL"- See notes below
Notes:
- TUS is a resumable protocol developed by Transloadit, The default endpoint is 'https://master.tus.io/files/' provided for test purposes by Transloadit
- XHRUpload uses the standard Ajax XmlHttpRequest. The default endpoint is 'https://example.cm/upload' and will fail!
- The widget is currently configured to allow between 1 and 3 image files (image/*) of up to 1MB each to be uploaded.
Work in progress
- TODO: Visibility and styling of upload failure error messages.
- TODO: Test edge cases for style inconsistencies.
- TODO: Find a way to allow multiple instances on a page with generated rather than explicit IDs.