Hi,

I installed the plugin and it works out of the box. But if I want to overwrite the #plupload_settings the javascript settings are not set, the default values are used.

How I use plupload in my template:

$form['my_element'] = array(
  '#type' => 'plupload',
  '#title' => t('Upload files'),
  '#description' => t('This multi-upload widget uses Plupload library.'),
  '#upload_validators' => array(
    'file_validate_extensions' => array('jpg')
  ),
  '#plupload_settings' => array(
    'runtimes' => 'html5,flash,html4',
    'chunk_size' => '2mb',
    'url' => url(path_to_theme().'/cal_editor_upload.php', array('query' => array('plupload_token' => drupal_get_token('plupload-handle-uploads')))),
  ),
);
print render($form['my_element']);

The pluploader is displayed correctly but the javascript is initiated with the default values. The problem seams to be #id because it's not set.

plupload.js problem
var elementSettings = (id && settings.plupload[id]) ? settings.plupload[id] : {};

Debugging of defaultSettings, elementSettings and pluploadSettings see attachment.
debug img

Many thanks for your plugin!
Best regards

Comments

Have you tried to set #id?

I tried it before, no luck. See image.

Code used:

$form['my_element'] = array(
  '#type' => 'plupload',
'#id' => 'fbdszuf6sd78gbdsgs67',
  '#title' => t('Upload files'),
  '#description' => t('This multi-upload widget uses Plupload library.'),
  '#upload_validators' => array(
    'file_validate_extensions' => array('jpg')
  ),
  '#plupload_settings' => array(
    'runtimes' => 'html4',
    'chunk_size' => '2mb',
    'url' => url(path_to_theme().'/cal_editor_upload.php', array('query' => array('plupload_token' => drupal_get_token('plupload-handle-uploads')))),
  ),
);
echo "<h1>Form element</h1>";
var_dump($form);
print render($form);

I tested this in a custom form and it works without problems.

Insepcting your code again I noticed that you use render() to display this. This is most likely the problem since this way #process never gets executed. You should try using drupal_get_form(), which is standard way of doing this.

Thank you!
It works.

Status:Active» Fixed

Great!

Status:Fixed» Closed (fixed)

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

Issue summary:View changes

img not working