/home/mip/www/vendor/laravel-filemanager/js/lfm.js
(function( $ ){
$.fn.filemanager = function(type, options) {
type = type || 'file';
this.on('click', function(e) {
var route_prefix = (options && options.prefix) ? options.prefix : '/laravel-filemanager';
localStorage.setItem('target_input', $(this).data('input'));
localStorage.setItem('target_preview', $(this).data('preview'));
window.open(route_prefix + '?type=' + type, 'FileManager', 'width=900,height=600');
window.SetUrl = function (url, file_path) {
//set the value of the desired input to image url
//var filename = file_path.substring(file_path.lastIndexOf('/') + 1, file_path.length);
//var thumbs_url = url.substring(0, url.lastIndexOf('/') + 1) + 'thumbs/' + filename;
//[ { "name": "unnamed.jpg", "url": "/storage/photos/5/unnamed.jpg", "time": 1709101790, "icon": "fa-image", "is_file": true, "is_image": true, "thumb_url": "/storage/photos/5/thumbs/unnamed.jpg" }]
myJSON = JSON.stringify(url, null, 4); // (Optional) beautiful indented output.
var str = myJSON;
var parse = JSON.parse(str);
var user = parse[0];
var filename = user.name;
var thumbs_url = user.thumb_url;
/* console.log(file_path);*/
var target_input = $('#' + localStorage.getItem('target_input'));
target_input.val(filename).trigger('change');
//set or change the preview image src
var target_preview = $('#' + localStorage.getItem('target_preview'));
target_preview.attr('src', file_path).trigger('change');
};
return false;
});
}
})(jQuery);