1 file.api.php hook_file_type($file)

Decides which file type (bundle) should be assigned to a file entity.


object $file: File object.

Return value

array: Array of file type machine names that can be assigned to a given file type. If there are more proposed file types the one, that was returned the first, wil be chosen. This can be, however, changed in alter hook.

See also



core/modules/file/file.api.php, line 436
Hooks for file module.


function hook_file_type($file) {
  // Assign all files uploaded by anonymous users to a special file type.
  if (user_is_anonymous()) {
    return array('untrusted_files');