UniSharp / laravel-filemanager

Media gallery with CKEditor, TinyMCE and Summernote support. Built on Laravel file system.
https://unisharp.github.io/laravel-filemanager/
MIT License
2.08k stars 720 forks source link

Callbacks more properties of the file #1204

Open B-MNSN opened 1 year ago

B-MNSN commented 1 year ago

I need the size of the file when confirm in filemaneger.

this my current callback

window.setURL = function(items) {
     items.icon
     items.is_file
     items.is_image
     items.name
     items.thumburl 
     items.time
     item.URL 
}

How get the size of file

streamtw commented 9 months ago

You can achieve this by modifying config/lfm.php.

Change from:

'item_columns' => ['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url'],

to below:

'item_columns' => ['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url', 'size'],

Then in you code block, you can iterate through items and get file size like:

window.setURL = function(items) {
    items.forEach((item) => {
        console.log(item.size)
    }
}