You are here

function file_entity_file_mimetype_mapping_alter in File Entity (fieldable files) 7.2

Same name and namespace in other branches
  1. 7.3 file_entity.file.inc \file_entity_file_mimetype_mapping_alter()
  2. 7 file_entity.module \file_entity_file_mimetype_mapping_alter()

Implements hook_file_mimetype_mapping_alter().

File

./file_entity.file.inc, line 162
File hooks implemented by the File entity module.

Code

function file_entity_file_mimetype_mapping_alter(&$mapping) {

  // For info on adding new mime-types to core: http://drupal.org/node/1443070.
  // @todo. Remove after fixing this in core http://drupal.org/node/2912875.
  // Add support for autocad drawings.
  $new_mappings['dwg'] = 'application/acad';

  // For info on adding new mime-types to file_entity: drupal.org/node/2900830.
  foreach ($new_mappings as $extension => $mime_type) {
    if (!in_array($mime_type, $mapping['mimetypes'])) {

      // If the mime type does not already exist, add it.
      $mapping['mimetypes'][] = $mime_type;
    }

    // Get the index of the mime type and assign the extension to that key.
    $index = array_search($mime_type, $mapping['mimetypes']);
    $mapping['extensions'][$extension] = $index;
  }
}