You are here

function media_get_type in D7 Media 7

Determines the type of media a passed in $file is.

@todo: integrate this properly with other APIs in media when fields is done

Parameters

unknown_type $file:

Return value

unknown_type

2 calls to media_get_type()
media_file_validate_types in ./media.module
Check that the media is one of the selected types.
media_get_thumbnail_preview in ./media.module
Returns a renderable array with the necessary classes to support a media thumbnail. Also provides default fallback images if no image is available.

File

includes/media.types.inc, line 170
Helper functions related to media types. CRUD for saving their settings mainly.

Code

function media_get_type($file) {
  $types = media_type_get_types();
  foreach ($types as $name => $type) {
    if (call_user_func_array($type->type_callback, array(
      $file,
      $type->type_callback_args,
    ))) {
      return $name;
    }
  }
  throw new Exception('Unable to determine type of media from ' . var_export($file, 1));
}