diff --git a/includes/mimetype.utils.inc b/includes/mimetype.utils.inc index 03708f99..81866fc8 100644 --- a/includes/mimetype.utils.inc +++ b/includes/mimetype.utils.inc @@ -22,6 +22,8 @@ function islandora_get_extension_for_mimetype($mimetype) { $mimetype_mapping = file_mimetype_mapping(); $extension_index = array_search($mimetype, $mimetype_mapping['mimetypes']); if ($extension_index !== FALSE) { + // Reversing such that any altered values take precedence over the default + // mappings. $mime_array_flipped = array_reverse($mimetype_mapping['extensions']); $extension = array_search($extension_index, $mime_array_flipped); } diff --git a/islandora.module b/islandora.module index 2dec1fd9..10d6060f 100644 --- a/islandora.module +++ b/islandora.module @@ -1662,6 +1662,12 @@ function islandora_file_mimetype_mapping_alter(&$mapping) { end($mapping['mimetypes']); $mapping['extensions'][$ext] = key($mapping['mimetypes']); } + // Get the current XML mapping and unset it so it comes last when we do our + // reverse when getting mimetypes from extensions for use in downloads. + // @see islandora_get_extension_for_mimetype. + $xml_int = $mapping['extensions']['xml']; + unset($mapping['extensions']['xml']); + $mapping['extensions']['xml'] = $xml_int; } /**