innostudio / fileuploader

Beautiful and powerful HTML file uploading tool. A jQuery, PHP and Node.js plugin that transforms the standard input into a revolutionary and fancy field on your page.
141 stars 25 forks source link

Array provided to 'preload' is reversed in rendered output #66

Closed wrabit closed 3 years ago

wrabit commented 3 years ago

My payload given to 'preload' is:

(renamed to my order column value for debugging)

[
   {
      "name":"\"1\"",
      "size":46011,
      "size2":"44.93 KB",
      "type":"image\/jpeg",
      ...
   },
   {
      "name":"\"2\"",
      "size":62579,
      "size2":"61.11 KB",
      "type":"image\/jpeg",
      ...     
   },
   {
      "name":"\"3\"",
      "size":62579,
      "size2":"61.11 KB",
      "type":"image\/jpeg",
      ...   
   },
   {
      "name":"\"4\"",
      "size":55983,
      "size2":"54.67 KB",
      "type":"image\/jpeg",
      ...
   }      
]

And the default output is:

image

My preload code:

        // preload existing files
        @this.preload()
          .then(result => {
            console.log(result)
            var api = $.fileuploader.getInstance($fileuploader),
                preload = []
            try {
              // preload the files
              preload = JSON.parse(result)
              api.append(preload)
            } catch (e) {}
          });

Console.log outputs:

image

Is this behaviour by design?

innostudio commented 3 years ago

@wrabit sorry for such a late answer. In custom.js you will find the option itemPrepend, set it false. Or you can reverse the array before preloading the files.

https://innostudio.de/fileuploader/documentation/#options-templates