Hi,

when uploading files with media module the allowed file extensions are always the default set. But these should be configurable. Actually it'd make sense to me that they depend on the media types selected for any multimedia asset respecting the general settings about the media types, where the file extensions already are configurable.

You can find a small patch attached implementing this functionality.

cheers

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xamanu’s picture

the patch hasn't been attached. here it comes...

JacobSingh’s picture

Status: Needs review » Needs work

Unfortunately, the media type definition is a little more complicated than this. Because you can specify a Mime type OR a list of extensions, this doesn't catch all cases.

I know the UX of setting it in two places sucks though.

I would recommend we expose the current setting for allowed extensions in the UI at least. And then, for bonus points, if someone puts in extensions when defining a type which are not on the master list we either add them or we notify them that they are not on the list.

Whattya think?

willmoy’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta2
Category: feature » bug
Priority: Normal » Critical

I had a curious experience just now:

Error message: The specified file whoopsie.pdf could not be uploaded. Only the following types of files are allowed to be uploaded: image, video

Upload a new file
Allowed file types: jpg jpeg gif png txt doc xls *pdf* ppt pps odt ods odp mp3 mov m4v mp4 mpeg avi ogg wmv ico.

It seems that the default settings allow extensions whose mime types are not allowed.

Moreover, the links in Home » Administration » Configuration » Media » Media Types go to admin/structure/media/manage/*, which doesn't exist.

What seems to exist is admin/config/media/types/manage/%media_type, but putting that (with substitutions) leads to a contentless page.

I think this counts as critical as you can only upload image and video?

Peter Feddo’s picture

Ditto.

The media type panel isn't displaying and so there's no way to configure the acceptable file types for upload.

james.elliott’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Category: bug » feature
Priority: Critical » Normal

There are 3 separate issues at hand.

The bug portion of this is fixed as #976598: Media settings redirect to Structure

There is a feature request to allow other media types in the WYSIWYG #1016376: Expose the media types allowed for WYSIWYG variable in the UI

And lastly, this issue should be a feature request for a functioning usable method of configuring mime types and extensions for media types.

JacobSingh’s picture

Title: configurable file extensions for upload » Improve usability of configuring media types / extensions and allowing uploads for those extensions

rename

hadsie’s picture

Category: feature » bug
Priority: Normal » Critical
Status: Needs work » Needs review
FileSize
450 bytes

There was actually another issue raised in #3 that hasn't been addressed which I'm also getting:

Error message: The specified file whoopsie.pdf could not be uploaded. Only the following types of files are allowed to be uploaded: image, video

I believe this /is/ a critical bug because it essentially prevents the module from being at all useable (possibly only on certain browser / OS configurations). I'm using Chrome with MAMP and getting this issue. (It won't let me upload /any/ videos even though the proper video extension is being uploaded).

This appears to be because of how media_is_type() validates the extension based on the media files uri.

if (in_array(pathinfo($media->uri, PATHINFO_EXTENSION), $args['extensions']))

Uploading a file for me from Chrome on MAMP has media->uri == /Applications/MAMP/tmp/php/phpoTpOCP which doesn't even have an extension, however filename does have the proper file and extension name. This patch is against the latest CVS code from head and changes uri to filename.

JacobSingh’s picture

Wow, thanks for the investigative work there.

It's quite odd I haven't seen it. I use Chrome and MAMP and so does most of our team The fix seems reasonable to me, but would like to know the cause. Have you tested it with the media_internet module to make sure that still works properly when adding from a URL?

What Chrome version?

Thanks!
Jacob

JacobSingh’s picture

Wow, thanks for the investigative work there.

It's quite odd I haven't seen it. I use Chrome and MAMP and so does most of our team The fix seems reasonable to me, but would like to know the cause. Have you tested it with the media_internet module to make sure that still works properly when adding from a URL?

What Chrome version?

Thanks!
Jacob

hadsie’s picture

I just did a quick test with the internet module and all seems good.

effulgentsia’s picture

Category: bug » feature
Priority: Critical » Normal
Status: Needs review » Needs work

@hadsie: I'm unable to reproduce what you're describing for video files that I've tried. #8 indicates you're trying a pdf file rather than a video, but perhaps that's just a copy/paste artifact. Anyway, I opened a new issue, #1024874: Add support for m4v as 'video/x-m4v' in file_entity_file_mimetype_mapping_alter(). Please respond there with more info. Thanks.

Setting issue attributes back to #7 state.

hadsie’s picture

Thanks @effulgentsia... in #8 I was actually just quoting from #3. The actual file I was uploading was an m4v and I'd configured the extensions appropriately. I forgot to mention my chrome version previously which is 8.0.552.231. MAMP is running PHP 5.3.2 and Apache 2.0.63. Will follow up on #1024874: Add support for m4v as 'video/x-m4v' in file_entity_file_mimetype_mapping_alter().

tsing’s picture

Status: Needs work » Needs review
thill_’s picture

So is this the right issue aiming to fix the issue of not being able to upload files like pptx ? It is odd that ppt is allowed but i can't upload pptx, and there is no place to alter this.

TripX’s picture

Priority: Normal » Major

+1

Also the well-known extension ".zip" is not allowed.

For me this is a major issue as it curtail the functionality of the module.

wuffers’s picture

Subscribing.

Thought I was overlooking something simple but the functionality to change allowed extensions isn't in yet. Tried to add webm to default MIME types but it still shows up as application/octet-stream in the media list.

Please add webm as an allowed video type (video/webm).

Cyberwolf’s picture

Subscribing.

RobW’s picture

@wuffers, Just ran into that today, .webm being read as an application. Doesn't work too well with file display.

Think I have it registered correctly by using hook_file_mimetype_mapping_alter in a custom module. The code:

function MYMODULE_file_mimetype_mapping_alter(&$mapping) {
  // Add new MIME type 'video/webm'.
   $mapping['mimetypes']['video_webm'] = 'video/webm';
  // Add new extension '.webm' and map it to the 'video/webm' MIME type.
  $mapping['extensions']['webm'] = 'video_webm';
 }

Believe that should fix the problem until this fix in file entity comes out of dev and into a stable release, at which point it will no longer be needed.

ParisLiakos’s picture

Project: D7 Media » File Entity (fieldable files)
Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Fixed

this is fixed in file_entity 2.x

Status: Fixed » Closed (fixed)

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