This is a quick patch that takes default max upload size from drupal and allows to configure the client-side resize parameters of plupload.

Comments

justintime’s picture

Status: Active » Needs review

Thanks for the patch, marking issue as 'needs review'.

shawn_smiley’s picture

StatusFileSize
new2.86 KB

Here is a patch for the Drupal 7 version of PLUpload.

You can control the max_upload_size and chunk_size settings either through the settings.php file or through the Variables module (the variables module is not required in order to use this patch).

shawn_smiley’s picture

StatusFileSize
new2.84 KB

Oops, left some debugging code in the previous patch. Here is a new patch without the debugging code.

crea’s picture

Subs

randallknutson’s picture

Just ran into this. At the very minimum I'd recommend changing the max_file_size to:

'max_file_size' => format_size(file_upload_max_size())

That way it will match whatever the file_upload_max_size of the system is. Hard coding it to 10mb will cause an error if it is set too low and will not allow anything over 10mb if it is set higher.

crea’s picture

Because the module works for uploading imagefield files, we should just use configured ImageField file size settings

slashrsm’s picture

Status: Needs review » Needs work

About D7 version:
We could add combination of both approaches: allow user to select max file size or to use system settings (which should be default, IMO). We should also explain how to control this settings in README.txt.

atlea’s picture

@randalknutson: Using file_upload_max_size as a default is a good idea. But note that because Plupload use chunked uploads, the PHP limits really does not apply (hooray!). format_size is not a good idea, at least without a language code as it could possibly translate KB, MB, etc to other abbreviations as it is passed through t(). Either way; Plupload can use byte as input - so no need to format the value.

@crea: This is a nice thought. The field using the element should control this setting per instance. The D7 version only has an element, and no fields, so a sane default would be all that is needed.

@slashrsm: I concur. Since field/forms using the element can control this, file_upload_max_size() should probably be the default. If you look at how filters (file extensions) are implemented in pre_render, using values from #upload_validators, file size should probably be set the same way? Then regular filed validations could be used, and one would not have to know how to set Plupload settings through #plupload_settings.

I have (just) implemented this functionality into http://drupal.org/sandbox/atlea/1414774. Since this is a field wrapper for the Plupload element (D7), I am using the (file) field instance settings to set the max size, and passing this to Plupload (element) using #plupload_settings (any Plupload settings can be set here, not just the ones that the Plupload module has defaults for). This works great. Thanks to chunked upload this can even be set higher than PHP file size/post size limits. I have not implemented client side resize (server side works) yet. I believe this should probably also (for D7) be left to the field/form implementing the Plupload element? Either by using #plupload_settings, or more ideally respecting file_validate_image_resolution if set in #upload_validators.

slashrsm’s picture

I think this also make a good point about this: http://drupal.org/node/1230632#comment-5669002

The more I think about configuration of this values, the more I am convinced, that we do not need it in D7. This module provides form element, which will always be used by other modules. I think we should leave them to implement UI configuration. Multiple configuration places for the same thing will just confuse users.