Extend default managed_file
widget, which is a part of Form API, by a set of useful features. See examples below to be involved.
Usage
These additional options for element with '#type' => 'managed_file'
is come with this module:
Add the Browse files
link before the file input to use one of available file managers:
// Also could be "ckfinder".
'#widget' => 'imce',
Tired to add an image styles for every managed file field?
// Add an additional "select" element with image styles.
'#styles' => TRUE,
Want a preview of the uploaded file?
// Append a preview of the uploaded file.
'#preview' => TRUE,
Also this module implements an API of the File MD5 module.
Complete example
$form['image'] = [
'#type' => 'managed_file',
'#title' => t('Image'),
// Also could be "ckfinder".
'#widget' => 'imce',
// Add an additional "select" element with image styles. When this is TRUE,
// then return value will be an array with two properties: "fid" and "style"
// instead of usual file ID as a string.
'#styles' => TRUE,
// Append a preview of the uploaded file.
'#preview' => TRUE,
];
Tracking the usage of file
Remember, that to successfully track the file in your Drupal system you have to invoke the managed_file_element_submit()
in a submit callback of the form.
Take a look at the module for testing as an example of complete implementation.
Project information
- Module categories: Developer Tools, Media
- 412 sites report using this module
- Created by BR0kEN on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Coding standards fixes
Development version: 7.x-1.x-dev updated 26 Apr 2017 at 02:19 UTC