1 file.module file_type_get_type($file)

Returns the file type of the passed file or file type string.

Parameters

File|string $file: A file entity or the machine name of the file type to return.

Return value

stdClass|FALSE: A single file type, as an object, or FALSE if the file type is not found. The file type is an object containing fields from a file type's config file.

File

core/modules/file/file.module, line 2316
Defines a "managed_file" Form API field and a "file" field for Field module.

Code

function file_type_get_type($file) {
  $type = is_object($file) ? $file->type : $file;
  $types = _file_types_build()->types;

  return isset($types[$type]) ? $types[$type] : FALSE;
}