Search code examples
jqueryfileapi

RubaXa jquery.fileapi setting preview el class


it is possible to set dynamically the class of the element that contain the preview of file based of the file type? For example for image file have:

preview:{"width":100,"height":100,"el":".image-div-class"}...

and for txt file have

preview:{"width":100,"height":100,"el":".text-div-class"}...

Thank you


Solution

  • To append not image files type to different div need to use:

    preview:{"width":100,"height":100,"el":".image-div-class""get":
                   function ($el, file) {
                       $el.appendTo(".file-type-'+file.name.split('.').pop()+'").append("<p>"+file.name+"</p>");;
                   }}