CMS Media Upload
Content management system media library interface. Upload, organize, and manage media files.
var uploader = new MultipleUpload(el, {
uploadUrl: '/api/upload',
autoUpload: true,
onTaskComplete: function(task) {
addToMediaLibrary({
name: task.name,
type: task.file.type,
size: task.file.size,
url: task.response.url
});
}
});
uploadBtn.addEventListener('click', function() {
uploader.openFileDialog();
});
Uploading into a content workflow
In a CMS the upload is the beginning: the file is stored, then it needs a record, a URL, alt text, a place in the library. onTaskComplete gives you the server's response per file, which is where that follow-on work is triggered.
Media libraries need the metadata
Name, type, size and dimensions are all available before the upload and in the response after it. Capturing them at this point is much easier than deriving them later, and it is what makes the library searchable rather than a folder of files.