summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgit2016-12-24 16:12:11 (GMT)
committerolstjos2016-12-24 16:12:11 (GMT)
commite8eb54ccc62e75186c475d4978c7c29187afb658 (patch)
treef2a4ff1abd38fbabbf248921572a188ff3187baa
parent51eaec01c375614e9e63457947b89db5d22fbd68 (diff)
Issue #2834464 by ann b: Multiple Files Attached in Reverse Order
-rw-r--r--includes/media.fields.inc8
-rw-r--r--js/media.js2
2 files changed, 7 insertions, 3 deletions
diff --git a/includes/media.fields.inc b/includes/media.fields.inc
index 5245d7a..81c9aba 100644
--- a/includes/media.fields.inc
+++ b/includes/media.fields.inc
@@ -309,7 +309,13 @@ function media_field_widget_process_multiple($element, &$form_state, $form) {
// For each file selected, increment the field key to be processed.
// field_mediafield_und_0 becomes field_mediafield_und_1, etc.
$_POST['media'][$upload_name_prefix . ($element['#file_upload_delta'] + $i)] = $files[$i];
- $element[] = $element[$element['#file_upload_delta']];
+
+ // Copy the default file element to each newly selected file position.
+ $default_element = $element[$element['#file_upload_delta']];
+ $element[] = array_merge(
+ $default_element,
+ array('#weight' => ($element['#file_upload_delta'] + $i + 1))
+ );
}
}
diff --git a/js/media.js b/js/media.js
index 607cd3a..bc7bb2a 100644
--- a/js/media.js
+++ b/js/media.js
@@ -94,8 +94,6 @@ Drupal.media.openBrowser = function (event) {
var mediaFileValue;
// Process the value based on multiselect.
if (mediaFiles.length > 1) {
- // Reverse array to have files in correct order
- mediaFiles.reverse();
// Concatenate the array into a comma separated string.
mediaFileValue = mediaFiles.map(function(file) {
return file.fid;