Download & Extend

Widget does not respect settings in file_field_instance_settings_form (uri scheme, directory, extensions, file size)

Project:Media
Version:7.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:D7 stable release blocker

Issue Summary

Coming from #1166168: Expose a widget for filefield and imagefield, so that media browser can be used for them and related to #1201920: Hide field and widget settings that the media widget cannot support, we need to respect filefield settings for filepath, etc, when using the widget on a filefield/imagefield.

Comments

#1

I set this as another issue, because it's probably slightly more difficult than the first.

#2

Subscribe.

#4

sub

#5

#6

Subscribe.

#7

sub

#8

Subscribing.

#9

+1 this would be very useful to have. But I hope the setting will only be used as a default, suggested, value that can be overridden by for example a media manager module or options set when uploading a new file.

#10

sub

#11

Version:7.x-1.x-dev» 7.x-2.x-dev

Moving this to the 2.x branch, setting backport tag.

#12

subscribing

#13

I've come up with a sort of workaround for this using the IMCE module. Requires a bit more work, but you get the files stored where you want them at lest.

You'll find it at the end of http://www.drupalmill.com/blog/tsvenson/2011/08/08/media-module-needs-fu...

#14

sub

#15

Title:Respect filefield settings for filepath» Respect file field settings in file_field_instance_settings_form (directory, extensions, file size, description field)

#16

Title:Respect file field settings in file_field_instance_settings_form (directory, extensions, file size, description field)» Widget does not respect settings in file_field_instance_settings_form (directory, extensions, file size, description field)

#17

...also public/private settings should be respected, currently its not. When using browser widget, files are always uploaded to public directory

#18

Sub

#19

sub

#20

subscribe! we would be willing to help, as we especially need the directory feature for media 7.x-1.x version.
Can anyone point me where I have to do what so that media field can have directories where they are saved?

#21

Subscribe and want to help too.
some guidance on this would be appreciated

#22

Has there been any progress on this?

#23

#13 worked for me but only for image files? I uploaded a PDF through IMCE but it did not show in media browser.

#24

sub

#25

Assigned to:Anonymous» becw

#26

sub

#27

Title:Widget does not respect settings in file_field_instance_settings_form (directory, extensions, file size, description field)» Widget does not respect settings in file_field_instance_settings_form (uri scheme, directory, extensions, file size)

We decided to form alter the description field out. This is better handled by fields on files.

#28

Assigned to:becw» Anonymous
Status:active» needs review

Here's a patch that uses the file extensions and file size from the file field instance for upload validation, and uses the file field instance file directory and file field URI scheme for saving the file.

This patch changes the parameters to media_add_upload(), which might be a problem--instead of providing an array of media types as the first parameter (after $form and &$form_state), it passes an array of parameters that includes the 'types' array. Woo, nested configuration arrays. If necessary, the parameters array could be an extra optional parameter instead.

This patch may require a followup issue for dealing with previews of private files--and possible ALL media display of private files.

AttachmentSizeStatusTest resultOperations
1201924-28-media-use_file_field_settings.patch6.18 KBIdlePASSED: [[SimpleTest]]: [MySQL] 0 pass(es).View details

#29

Status:needs review» needs work

We need to use some similar logic from file_field_widget_upload_validators():

<?php
 
// Cap the upload size according to the PHP limit.
 
$max_filesize = parse_size(file_upload_max_size());
  if (!empty(
$instance['settings']['max_filesize']) && parse_size($instance['settings']['max_filesize']) < $max_filesize) {
   
$max_filesize = parse_size($instance['settings']['max_filesize']);
  }
?>

#30

Status:needs work» needs review
AttachmentSizeStatusTest resultOperations
1201924-media-use_file_field_settings.patch6.28 KBIdlePASSED: [[SimpleTest]]: [MySQL] 0 pass(es).View details

#31

Status:needs review» reviewed & tested by the community

Tested successfully on 2.x and 1.x. Ran automated tests successfully as well.

#32

Status:reviewed & tested by the community» fixed

Committed #30 to Git (attributed to becw) and 7.x-1.x and 7.x-2.x.
http://drupalcode.org/project/media.git/commit/0b95bf8
http://drupalcode.org/project/media.git/commit/d18f7ae

#33

Status:fixed» closed (fixed)

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

#34

Status:closed (fixed)» active

I'm sorry to re-open this issue, but it's not immediately clear to me how this commit accommodates the support request originally made here: #1096374: Provide administrator with ability to customize upload directory, globally and per-field, with token integration and in particular the need to specify a custom upload directory for files uploaded from admin/content/file, as opposed to files uploaded via a field on a node or entity. To be clear, files uploaded via the media browser widget on an image-field or file-field are respecting custom directory settings (and tokens! Whew!). But is there a means to specify a custom upload directory when using the media browser at admin/content/file, so that all files uploaded here do not live at the top level of one's public file system path?

#35

Hey stephen... In #1243006: Uploading a textarea image to a particular folder, one of the Media maintainers (arthurf) stated that he felt this functionality was better handled by an add-on module. To that end, I've created a sandbox project called Media upload directory that provides default directories by file type, regardless of whether the media file is attached to a field.

The implementation was pretty simple (just a config form and a few lines of additional validation on upload), so I'd love it if arthurf or another Media maintainer could take a look at that sandbox and reconsider whether or not this should be included directly in Media. If yes, then I can reformulate it as a patch and post here. If not, I'll promote to a full project and maintain it separately. Thanks!

#36

Muriqui, thanks so much for your work on the upload directory module. I'm going to test it out and i'll be sure to list any findings/bugs/whatever in its issue queue. I think this kind of functionality belongs in the media module itself, simply because it resolves such a seemingly fundamental need: file organization.

#37

Subscribe

#38

@Andrea C NO! Follow, don't subscribe. http://drupal.org/node/1306444

#39

Status:active» closed (fixed)

The admin/content/file directory lacks any kind of 'field context' so if you want that type of feature you need to open a new feature request. This bug as originally reported is being marked back as fixed.

#40

could you use filefield_paths to get what you need?

#41

My experience is that when you use the Media widget on an ImageField, it respects the proper file path. However, when I use the Media WYSIWYG editor button, it does not respect it, and places it into the default "files" directory. I'm guessing this still needs to be fixed?

EDIT: Apologies, I just noticed this bug is listed for 7.x-2.x, whereas I'm using 7.x-1.x. (It's a site that I'm building for a client, so I need a stable release.) Perhaps this is the wrong place to post this then?