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.
Hi,
When you choose some files to upload, don't click on the "Upload" button, and save your node, files are not uploaded, like the core file widget.
So I have created this little Javascript snippet to display an alert to the user when there are files waiting for upload :
//Compter le nombre de tr dans la liste des photos à uploader. Si < 1, on affiche un message pour dire qu'il y a des photos non uploadées
jQuery('#edit-submit').click(function(){
if('#edit-field-photos-und-plup-filelist'){
var rowCount = jQuery('#edit-field-photos-und-plup-filelist > table > tbody > tr').length;
if(rowCount > 1) {
alert('Becareful, you have some files waiting for upload !');
return false;
}
}
});
Joel
Comments
Comment #1
akk CreditAttribution: akk commentedCould you add some more info please? which file this snippet supposed to be added to do the check? thank you in advance.
Comment #2
joelrotelli CreditAttribution: joelrotelli commentedYou can add this snippet in a custom JS file (just declare it in your .info file)
Comment #3
Sinan Erdem CreditAttribution: Sinan Erdem commentedHello and thanks for the code snippet.
I suppose it will be better if we automatically upload the images when the user saves the node. Normal Drupal imagefield widget works like that.
There is also a module for this purpose: https://drupal.org/project/autoupload Maybe integration is possible.