Hi all!

I am using Multiupload Filefield Widget and Multiupload Imagefield Widget to create an image field, which is attached to a Profile2 profile (https://drupal.org/project/profile2).

The thing is that the field is acting very weird when uploading files. First time it uploads correct, but next times it breaks and is not uploading anything until you remove all the images and start uploading again from the first.

It is very strange because this module is working as charm when the field is attached to a node bundle for example.
I tested on 2 servers, and on several different drupal installations because I was suspicious about different things.

Here is a screenshot of the weird behavior of the field:
If you try to upload 4 images - it generates 4 fields for uploading images. Also it acts the same in firefox and chrome, where it also works nice when attached to node bundle.

Does someone have the same problem and is there a workaround for this?

Comments

meadmclean’s picture

Yeah there is a discussion of this under the multiupload imagefield widget issues.
https://drupal.org/node/1504390

andrew.fulton’s picture

I found this problem while working with the Inline Entity Form module, it _seems_ to be caused by the mfw_managed_file_value() doesn't find the correct file_upload_delta and subsequently can't find the uploaded files in the FILES array.

Specifically in mfw_managed_file_value() where it does this:

$element['#file_upload_delta_original'] = isset($form_state['complete form'][$element['#parents'][0]][$element['#parents'][1]]['#file_upload_delta']) ? $form_state['complete form'][$element['#parents'][0]][$element['#parents'][1]]['#file_upload_delta'] : 0;

It should possibly do something like this:

$element_parent = drupal_array_get_nested_value($form_state['complete form'], array_slice($element['#parents'],0,-1));
$element['#file_upload_delta_original'] = isset($element_parent['#file_upload_delta'])? $element_parent['#file_upload_delta'] : 0;

So that the depth isn't hardcoded and it can find the #file_upload_delta properly. It seems to work, I am not sure of a reason why this would break anything. I'll try to post an actual patch when I remember how to do that

andrew.fulton’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1.01 KB
meadmclean’s picture

Nice work! I'll try this out on my test site soon.

raulmuroc’s picture

Patch of #3 worked perfectly with 7.x-1.12 in my website :)

All images uploaded in a profile2 image field. Tried with different users of different roles.

+1 reviewed!

---
Extra note: Perhaps is not related to this module but I put here because it happened first with MultiUpload (not with single upload).

Once the images are uploaded and I got back to Profile2 there are some shown, some not in my Views Slideshow. I need to make a page refresh (F5) and then they are all correctly shown. Maybe it is problem of Views Slideshow instead, I do not know. <-- to clarify this point more testing of others would be appreciated and needed. Thanks!
--
Extra note 2: Ok, it is happening the same when I'm going to Profile2 in "edit" mode. First time I got in some pictures are shown some not in the "thumbnail preview image". When I reload the page with F5 they are correctly shown.

So it points is something related to this module, not Views slideshow.

czigor’s picture

Status: Needs review » Fixed

This has been fixed in https://drupal.org/comment/8343973#comment-8343973. However, I like the brevity of this solution so I'm committing this, too.

Thanks!

201ca6a8c9c08074386684688826bc4748a3147a Issue #2067083 by andrew.fulton: The field is not working properly when it is assigned to Profile2 entity

czigor’s picture

@RaulMuroc: For the problems described in the extra notes please open a separate issue if you are still experiencing them.

Status: Fixed » Closed (fixed)

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