1 file.api.php hook_file_type($file)

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

Parameters

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

hook_file_type_alter()

File

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

Code

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');
  }
}