dropzone.js - Programmatically Add Existing File to Dropzone -
i'm trying add existing image dropzone programmatically, using dropzone.js faq guide:
// add existing image if it's there. // headerdropzone dropzone (debug shows existing , initialized @ point. var on_load_header = $( '[name="on_load_header_image"]' ).val(); var on_load_header_path = $( '[name="on_load_header_image_path"]' ).val(); if ( on_load_header ) { // hardcoded size value testing, see second question below. var on_load_header_data = { name: on_load_header, size: 12345 }; // call default addedfile event handler headerdropzone.options.addedfile.call( headerdropzone, on_load_header_data ); // , optionally show thumbnail of file: headerdropzone.options. thumbnail.call( headerdropzone, on_load_header_data, on_load_header_path); }
my first problem not working. addedfile event doesn't fire (or @ least addedfile handler in headerdropzone
never fires), same goes thumbnail.
my second problem/question is: have provide file size? server side, i'd rather not if don't need to.
see if functions headerdropzone.options.addedfile
, headerdropzone.options.thumbnail
defined. should work way did it, without further info it's difficult tell what's wrong.
about filesize: no, it's not necessary provide accurate filesize. it's dropzone automatically displays filesize. if don't care if false filesize displayed can provide random number or 0
. otherwise might want hide filesize css, or js after add it. (the element in question has class dz-size
.
the javascript version of this:
var filesizeelement = on_load_header_data.previewelement.queryselector(".dz-size"); filesizeelement.parentnode.removechild(filesizeelement);
Comments
Post a Comment