Some default configuration for the plupload widget is created at:

  • File plupload.libraries.yml: Static
  • hook_library_info_alter (): More or less dynamic, depending on server settings

These configurations should make their way to the Drupal.behaviors.plupload javascript behaviour, but they don't.
This can be easily tested around lines 32-34 from plupload.js:

      var defaultSettings = settings.plupload['_default'] ? settings.plupload['_default'] : {};
      var elementSettings = (id && settings.plupload[id]) ? settings.plupload[id] : {};
      var pluploadSettings = $.extend({}, defaultSettings, elementSettings);
      console.log(settings.plupload);console.log(pluploadSettings);

Only settings defined at PlUploadFile::preRenderPlUploadFile() appear on the javascript, so very useful settings like unique_names, max_file_size, chunk_size do not get an appropiate default.

CommentFileSizeAuthor
#2 default_settings_ignored-2592641-2.patch783 bytesbudalokko
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

budalokko created an issue. See original summary.

budalokko’s picture

Status: Needs work » Needs review
FileSize
783 bytes

Attached patch solves the problem. It loads the default settings on the form element too, so they are available in Drupal.behaviors.plupload.

I have compared our way of defining JavaScript settings with some other modules (color, locale, js_example) and they don't define their settings in MODULENAME.libraries.yml and hook_library_info_alter as we do. They usually build the settings directly at $element['#attached']['drupalSettings'].

In this patch I have kept the definitions in MODULENAME.libraries.yml and hook_library_info_alter because the dynamic parts of the settings (those calculated in plupload_library_info_alter) seem reasonable to be calculated once and kept until cache rebuild, instead of calculating them on each page load.

budalokko’s picture

Status: Needs review » Closed (fixed)