Browse Source

include islandora mimetypes in drupal mimetype mappings

pull/347/head
Nelson Hart 12 years ago
parent
commit
6424a97495
  1. 11
      includes/mime_detect.inc
  2. 23
      islandora.module

11
includes/mime_detect.inc

@ -366,4 +366,15 @@ class MimeDetect {
return $out;
}
/**
* Gets MIME type array.
*
* @return array
* returns associative array with exts and mimetypes
*/
public function getMimeTypes() {
return $this->protectedMimeTypes;
}
}

23
islandora.module

@ -1097,3 +1097,26 @@ function islandora_download_clip(AbstractObject $object) {
}
exit();
}
/**
* Implements hook_file_mimetype_mapping_alter().
*
* Grab custom islandora mime type list and add any missing ext/mimes to the drupal mapping
*
* @param array $mapping
* The Drupal mimetype mapping.
*/
function islandora_file_mimetype_mapping_alter(&$mapping) {
$mime_detect = new MimeDetect();
$types = $mime_detect->getMimeTypes();
$diff = array_diff_key($types, $mapping['extensions']);
foreach ($diff as $ext => $mime) {
if (!isset($mapping['extensions'][$ext])) {
$mapping['mimetypes'][] = $mime;
$last = end($mapping['mimetypes']);
reset($mapping['mimetypes']);
$key = array_search($mime, $mapping['mimetypes']);
$mapping['extensions'][$ext] = $key;
}
}
}
Loading…
Cancel
Save