Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#8 | media_983924.patch | 450 bytes | hadsie |
#1 | media-configurable-file-extensions-983924-1.patch | 1.75 KB | xamanu |
Comments
Comment #1
xamanu CreditAttribution: xamanu commentedthe patch hasn't been attached. here it comes...
Comment #2
JacobSingh CreditAttribution: JacobSingh commentedUnfortunately, 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?
Comment #3
willmoy CreditAttribution: willmoy commentedI 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?
Comment #5
Peter Feddo CreditAttribution: Peter Feddo commentedDitto.
The media type panel isn't displaying and so there's no way to configure the acceptable file types for upload.
Comment #6
james.elliott CreditAttribution: james.elliott commentedThere 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.
Comment #7
JacobSingh CreditAttribution: JacobSingh commentedrename
Comment #8
hadsie CreditAttribution: hadsie commentedThere was actually another issue raised in #3 that hasn't been addressed which I'm also getting:
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.
Comment #9
JacobSingh CreditAttribution: JacobSingh commentedWow, 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
Comment #10
JacobSingh CreditAttribution: JacobSingh commentedWow, 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
Comment #11
hadsie CreditAttribution: hadsie commentedI just did a quick test with the internet module and all seems good.
Comment #12
effulgentsia CreditAttribution: effulgentsia commented@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.
Comment #13
hadsie CreditAttribution: hadsie commentedThanks @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().
Comment #14
tsing CreditAttribution: tsing commented#1: media-configurable-file-extensions-983924-1.patch queued for re-testing.
Comment #15
thill_ CreditAttribution: thill_ commentedSo 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.
Comment #16
TripX CreditAttribution: TripX commented+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.
Comment #17
wuffers CreditAttribution: wuffers commentedSubscribing.
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).
Comment #18
Cyberwolf CreditAttribution: Cyberwolf commentedSubscribing.
Comment #19
RobW CreditAttribution: RobW commented@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:
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.
Comment #20
ParisLiakos CreditAttribution: ParisLiakos commentedthis is fixed in file_entity 2.x