This patch removes the longstanding issue with drupal_add_js()'s use of array_merge_recursive() which prevent uc_option_images from working when more than one node was displayed at a time. Working around this issue required several tricks:
- Access DOM elements that are children of the context returned by Drupal Behaviors (for the form elements), or access them by unique ID (for the image block div)
- Abandon the use of a global 'nodeid' settings attribute in favour of a hidden form value containing the node ID, added by a form_alter hook
- Use $prep to ensure that the global settings are only ever added/merged on the first call
- Use a string array index for the node IDs of $data['images'] so that array_merge_recursive() doesn't append the numerical keys, which is what would cause the bizarre and duplicated JS setting arrays
Note that this patch builds on/requires the Drupal Behaviors patch posted in comment #43 of.