Helper: filemanager/util/browser

« All helpers

Provides a modal dialog to browse for files.

Usage:

1. Load this handler either in your handler:

$this->run ('filemanager/util/browser');

Or anywhere in your view:

 {! filemanager/util/browser !}

2. Use the $.filebrowser() function to open the dialog window:

 $.filebrowser ({
     allowed: ['jpg', 'jpeg', 'png', 'gif'],
     set_value: '#field-id',
     title: 'Choose an image',
     thumbs: true,
     callback: function (file) {
         console.log ('You chose: '  + file);
     }
});

Options:

  • allowed - An array of allowed file extensions.
  • callback - A function to call with the chosen file link.
  • set_value - The selector of an input field to update with the chosen file link.
  • thumbs - Whether to show thumbnails instead of file names. Note: also automatically sets allowed list to jpeg, png, and gif formats so you don't have to set allowed explicitly.
  • title - A custom title for the dialog window.