Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When we use upload.js in imagefield for example, we can't upload more than one file at the same time, since Drupal uses one iframe for all uploads, so only one completes.
This patch changes drupal.js and upload.js so that each upload gets it's own iframe, so we can upload as many files as we want in parallel.
Also, in the patch are some fixes so that everything works with Opera.
I moved the iframehandler to it's own function, so it works with Opera. When it was part of the bigger function, Opera fired it straight away, instead of only oncomplete.
Review and tell me what you think,
Bojan
Comment | File | Size | Author |
---|---|---|---|
drupal_upload.patch | 8.78 KB | bojanz | |
Comments
Comment #1
Steven CreditAttribution: Steven commentedI like the idea of this patch, but just looking through the code it doesn't appear quite right:
(removed '-' lines)
handlers, button and action are not declared, and the latter are only initialized if 'handlers' is undefined. This is the case if handlers == object, the code will pass undefined values into Drupal.createIframe for target/action. This is not right.
If this code still works, that means that the if-check always succeeds and is in fact redundant.
Also, code like this is silly:
jQuery can select by id immediately, there is no need to iterate like this.
Comment #2
bojanz CreditAttribution: bojanz commentedI must admit I am not a JS expert, so anyone is free to improve the code.
The code doesn't look right maybe, but it works.
This condition is true for the first time we upload, and false for every other time we upload (an imagefield for example).
So, if handlers is not set, we set the required data, and it persists to be used in other requests.
Without that code, action gets rewritten in the second upload with the wrong value (leading to imagefield/js).
As, for the second code you listed, Drupal does it this way, this is from the vanilla upload.js
This line:
Was making problems in Opera (didn't work), so I replaced it with code in style with the code 5 lines above, the iteration:
So we get the same effect, but with opera working.
Feel free to correct the code if you know how, this is the best I can do.
Comment #3
p_palmer CreditAttribution: p_palmer commentedSomething slightly wrong here....
How to recreate: Use FF and Web developer 1.1.4 extension, then Use Ctrl-Shift-F to Display Element Information...
I am not using multiple images per my particular content type.
Each time a user selects 'upload', the current preview image will be overwritten with the new - fine.
However, there is an extraneous "div" and "div #field-image-attach-wrapper" added when there should not be.
Web developer output...
html .js > body .sidebars > div #wrapper > div #container .clear-block > div #center > div #squeeze > div .right-corner > div .left-corner > form #node-form > div > div .node-form > div .standard > div #field-image-attach-wrapper > div > div #field-image-attach-wrapper > fieldset .collapsible > div .fieldset-wrapper > div .imagefield-edit-image-row clear-block
This section...
div .standard > div #field-image-attach-wrapper > div > div #field-image-attach-wrapper > ...
should read...
div .standard > div #field-image-attach-wrapper > ...
When a new image is uploaded, the markup goes away, however, it is quite important that this feature not happen if at all possible.
Can anyone else spot this bug?
Thanks in advance
Comment #4
PanchoAnother bug that IMHO should be fixed in D6.
Comment #5
dpearcefl CreditAttribution: dpearcefl commentedIs this still a need in D6? If so, who wants to supply a patch?