When I use the mupload widget I can not use the row weights to reorder the images. I rearrange the images and click save and they all go back to the original order.

When I switch the widget back to image, I can rearrange the images and save and they keep their order.

Comments

michèle’s picture

i have the same problem...
it seems that the "delta" field is not updated after saving a resorted node.

Gman’s picture

StatusFileSize
new1.45 KB

I have attached a patch that includes the delta processing. Seems that not all of the file.field.inc ...field_widget_process_multiple function was used. I have included the rest of the processing.

I haven't noticed any new issues popping up.

fedik’s picture

also plus patch from #2 my fix for

Notice: Undefined index: _weight in _field_sort_items_helper() (line 518 .../modules/field/field.module).
Notice: Undefined index: _weight in _field_sort_items_helper() (line 519 .../modules/field/field.module).

it add new files in to end of a files list
in function mupload_managed_file_save_upload

--- a/mupload.module
+++ b/mupload.module
@@ -349,9 +376,10 @@ function mupload_managed_file_save_upload($element, $input, $form_state) {
   if ($element['#type'] != 'plupload') {
     return FALSE;
   }
-
   $files = plupload_element_value($element, $input, $form_state);
 
+  //get last weight
+  $weight = !empty($form_state['values'][$element['#field_name']][LANGUAGE_NONE]) ? count($form_state['values'][$element['#field_name']][LANGUAGE_NONE])  : 0 ;
   $return = array();
   foreach($files as $file_number => $file_info) {
     $destination = isset($element['#upload_location']) ? $element['#upload_location'] : NULL;

--- a/mupload.module
+++ b/mupload.module
@@ -369,8 +397,10 @@ function mupload_managed_file_save_upload($element, $input, $form_state) {
       // return FALSE;
       continue;
     }
-
+    
+    $file->_weight = $weight;
     $return[] = $file;
+    $weight++;
   }
   return $return;
 }
sachbearbeiter’s picture

Component: User interface » Code

subscribe

mavimo’s picture

StatusFileSize
new2.16 KB

Patch with #2 and#3

robertom’s picture

Status: Active » Needs review
hydra’s picture

Status: Needs review » Reviewed & tested by the community

The patch looks good to me! Thanks

rv0’s picture

Thanks for the patches, #5 saved my day ;)