Posted by arthurf on September 25, 2011 at 9:09pm
6 followers
Jump to:
| Project: | Drupal core |
| Version: | 7.x-dev |
| Component: | file system |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
| Issue tags: | Media Sprint 2011, needs backport to D7 |
Issue Summary
file.mimetypes does not have an entry for video/x-m4v m4v which prevents these video files' mime type from being properly detected.
Attached patch adds this entry to our listing.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| mimetype.patch | 613 bytes | Idle | PASSED: [[SimpleTest]]: [MySQL] 33,055 pass(es). | View details |
Comments
#1
This directly matches the information at http://en.wikipedia.org/wiki/M4V.
#2
RTBC pending testbot review
#3
#4
I just stumbled upon this issue while reviewing some of the great work being done on the media module; it looks like the version was set to 7.x-dev by mistake?
I'm moving this to 8.x and changing the status to needs review. I'll change it back to RTBC after the testbot runs.
I conditionally apologize if I'm wrong about this!
#5
mimetype.patch queued for re-testing.
#6
#7
Confirming this is ready against both 8.x and 7.x.
#8
Committed to 8.x, moving to 7.x for webchick to look at.
#9
Committed and pushed to 7.x. Thanks!
Though one question. Is it possible a contributed module has already used ID 348 for something else..?
#10
They should be adding their entries properly. If not, then it's a bug in that module:
<?php
/**
* Implements hook_file_mimetype_mapping_alter().
*/
function file_entity_file_mimetype_mapping_alter(&$mapping) {
// Fix the mime type mapping for ogg.
// @todo Remove when <a href="http://drupal.org/node/1239376" title="http://drupal.org/node/1239376" rel="nofollow">http://drupal.org/node/1239376</a> is fixed in core.
$new_mappings['ogg'] = 'audio/ogg';
// Add support for m4v.
// @todo Remove when <a href="http://drupal.org/node/1290486" title="http://drupal.org/node/1290486" rel="nofollow">http://drupal.org/node/1290486</a> is fixed in core.
$new_mappings['m4v'] = 'video/x-m4v';
// Add support for mka and mkv.
// @todo Remove when <a href="http://drupal.org/node/1293140" title="http://drupal.org/node/1293140" rel="nofollow">http://drupal.org/node/1293140</a> is fixed in core.
$new_mappings['mka'] = 'audio/x-matroska';
$new_mappings['mkv'] = 'video/x-matroska';
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;
}
}
?>
#11
Right, I understand that. But
$mapping['mimetypes'][] = $mime_type;in an array$mapping['mimetypes']with 348 items already in it would give you an ID of 348... no? Or does it not matter, since the code always refers to$mapping['extensions'][$extension]instead?#12
No, the id of $mime_type in this case would be 349. The key is using it properly.
#13
Webchick- from your question in #9, I'm guessing that we could have a function which does basically what file_entity_file_mimetype_mapping_alter() is doing so that modules implementing the alter hook do not risk hard coding the keys. Possibly an extension/mimetype register hook.
More simply we could modify the text of http://api.drupal.org/api/drupal/modules--system--system.api.php/functio... to give a better example of how to implement this hook without creating collisions.
#14
Automatically closed -- issue fixed for 2 weeks with no activity.