We're missing mimetype support for some popular e-book formats:

Amazon Kindle (.azw) = application/vnd.amazon.ebook
EPub (.epub) = application/epub+zip
MobiPocket (.prc, .mobi) = application/x-mobipocket-ebook

Comments

becw’s picture

Assigned: Unassigned » becw
becw’s picture

Assigned: becw » Unassigned
Issue tags: +Novice

I'm going to leave this for someone who's new to core development :)

crashtest_’s picture

Assigned: Unassigned » crashtest_
crashtest_’s picture

Status: Active » Needs review
StatusFileSize
new1.45 KB

Added the above mimetypes.

dave reid’s picture

Title: Add support for popular e-book formats in file_default_mimetype_mapping() » Add support for popular e-book formats, mkv and mka, and weba, webm, and webp in file_default_mimetype_mapping()

Let's not have three separate file mime type issues open because they will naturally conflict with each other. Let's merge #1293140: Add support for mkv and mka file extensions and #1347624: Add support for the Google web file types: weba, webm, and webp into this issue and let CrashTest_ at it!

dave reid’s picture

For reference:

File extension: mkv
Mime type: video/x-matroska

File extension: mka
Mime type: audio/x-matroska

File extension: .webp
Mime type: image/webp

File extension: .weba
Mime type: audio/webm

File extension: .webm
Mime type: video/webm

File extension: vtt
Mime type: text/vtt

crashtest_’s picture

Title: Add support for popular e-book formats, mkv and mka, and weba, webm, and webp in file_default_mimetype_mapping() » Add support for popular e-book formats in file_default_mimetype_mapping()
StatusFileSize
new2.04 KB

Adding the other two extensions from very similar issue: http://drupal.org/node/1293140 - add support for mka and mkv.

dave reid’s picture

Title: Add support for popular e-book formats in file_default_mimetype_mapping() » Add support for popular e-book formats, Google web formats, mkv and mka in file_default_mimetype_mapping()
dave reid’s picture

Issue tags: +Needs backport to D7

Adding backport tag.

crashtest_’s picture

Added support for the following extensions:
+ 'azw' => 349,
+ 'epub' => 350,
+ 'mobi' => 351,
+ 'prc' => 352,
+ 'mkv' => 353,
+ 'mka' => 354,
+ 'webp' => 355,
+ 'weba' => 356,
+ 'webm' => 357,
+ 'vtt' => 358,

saltednut’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new14.31 KB
new55.48 KB

#10 applies cleanly. Tested using 10 files with the extensions in question.

Here are a couple of screenshots showing the new mimetypes at work:

Screen Shot 2012-07-26 at 2.10.39 PM.png
Screen Shot 2012-07-26 at 2.12.28 PM.png

catch’s picture

Status: Reviewed & tested by the community » Needs work

Any reason why these are being added with out of sequence array indices?

+++ b/core/includes/file.mimetypes.incundefined
@@ -64,6 +65,7 @@ function file_default_mimetype_mapping() {
       25 => 'application/rss+xml',
       26 => 'application/rtf',
       27 => 'application/smil',
+      349 => 'application/vnd.amazon.ebook',
       28 => 'application/vnd.cinderella',
       29 => 'application/vnd.google-earth.kml+xml',

Let's re-number the array instead of putting out of sequence array indices.

dave reid’s picture

Status: Needs work » Reviewed & tested by the community

If we want to re-order them to not be alphabetical, then we should probably file that as a follow-up. Ordering them in alphabetically is wonky, but it does make sense, and it's how we've been extending this list so far. It also makes the mime types easier to find when doing a visual scan.

See: http://api.drupal.org/api/drupal/core%21includes%21file.mimetypes.inc/fu...

      332 => 'video/quicktime', 
      333 => 'video/vnd.mpegurl', 
      347 => 'video/x-flv', 
      334 => 'video/x-la-asf', 
      348 => 'video/x-m4v', 
      335 => 'video/x-mng', 
      336 => 'video/x-ms-asf',

I think this should still be RTBC to get it in, and re-order if we want to afterwards.

catch’s picture

Status: Reviewed & tested by the community » Needs work

We should just re-index the array - i.e. have it both alphabetical, and the numeric keys in sequence. That will mean the index changes for some file types but that should be a problem since code shouldn't be dealing with the indexes directly anyway.

I don't see a reason not to fix that before this goes in, the fact that another patch already made it wonky doesn't feel like a reason to make it even worse.

albert volkman’s picture

I'm not entirely familiar with the usage here, but if the code should never deal with the indexes directly, then why do we have them? Could we just do away with them entirely?

dave reid’s picture

Issue tags: +sprint
dave reid’s picture

I would much rather list our extensions and mime types using the following:

  $mapping['gif'] = 'image/gif';
  $mapping['jpg'] = $mapping['jpeg'] = 'image/jpeg';

catch do you think this is better? If so I'm ok with refactoring this function to use this syntax for D8 as a blocker to this issue.

Jorrit’s picture

Is it possible to have patch #10 applied to Drupal 8 and backported to 7 before this refactoring process is started? Or just to Drupal 7?

dave reid’s picture

Status: Needs work » Needs review
dave reid’s picture

Status: Needs review » Reviewed & tested by the community

I must insist that we follow-up with cleaning up the list in a separate issue because that itself would not be backported to Drupal 7.

dave reid’s picture

catch’s picture

I think we could backport a re-numbering of the array to D7, assigning to David for comment.

David_Rothstein’s picture

Assigned: David_Rothstein » Unassigned

Well, if my reading of hook_file_mimetype_mapping_alter() is correct, those numbers are actually meaningful (people are intended to refer to them directly in the alter hook, as in the example code used there)... If that's the case, we shouldn't renumber them in Drupal 7.

alexpott’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

There is precedence for adding mimetypes out of order see #370958: FLV Flash Video Mimetypes. I don't think we should get to hung up on the order of the array - preserving the numbers for existing code seems more in our interests.

Committed fc4150b and pushed to 8.x. Thanks!

ByronNorris’s picture

Issue summary: View changes
Status: Patch (to be ported) » Needs review
StatusFileSize
new2.91 KB
new52.05 KB
new12.03 KB

Uploading D7 backport containing the mimetypes from ExtensionMimeTypeGuesser.php in 8.x branch. List remains out of order. Screenshots attached of the new mimetypes working properly.

dcam’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -sprint
StatusFileSize
new26.03 KB

Looks good to me. RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 25: file-ebook-mime-types-1443070-25.patch, failed testing.

dcam’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 25: file-ebook-mime-types-1443070-25.patch, failed testing.

dcam’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 25: file-ebook-mime-types-1443070-25.patch, failed testing.

dcam’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 25: file-ebook-mime-types-1443070-25.patch, failed testing.

dcam’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 25: file-ebook-mime-types-1443070-25.patch, failed testing.

dcam’s picture

Status: Needs work » Reviewed & tested by the community
David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x - thanks!

  • David_Rothstein committed 8cf521c on 7.x
    Issue #1443070 by CrashTest_, bluegriff | Dave Reid: Added support for...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.