Index: extensions/BatchDownloader/admin/sets.php
===================================================================
--- extensions/BatchDownloader/admin/sets.php	(revision 23167)
+++ extensions/BatchDownloader/admin/sets.php	(revision 23280)
@@ -6,7 +6,6 @@
 {
   $BatchDownloader = new BatchDownloader($_GET['delete']);
-  $BatchDownloader->deleteLastArchive();
-  $BatchDownloader->clearImages();
-  pwg_query('DELETE FROM '.BATCH_DOWNLOAD_TSETS.' WHERE id = '.$_GET['delete'].';');
+  $BatchDownloader->delete();
+  unset($BatchDownloader);
 }
 if (isset($_GET['cancel']))
@@ -17,4 +16,5 @@
   $BatchDownloader->deleteLastArchive();
   $BatchDownloader->clearImages();
+  unset($BatchDownloader);
 }
 if (isset($_POST['delete_done']))
@@ -84,4 +84,6 @@
     )
     ));
+  
+  unset($set);
 }
 
Index: extensions/BatchDownloader/include/BatchDownloader.class.php
===================================================================
--- extensions/BatchDownloader/include/BatchDownloader.class.php	(revision 23167)
+++ extensions/BatchDownloader/include/BatchDownloader.class.php	(revision 23280)
@@ -209,12 +209,21 @@
   function addImages($image_ids)
   {
+    global $conf;
+    
     if (empty($image_ids) or !is_array($image_ids)) return;
     
-    $image_ids = array_unique($image_ids);
+    $query = '
+SELECT id, file
+  FROM '.IMAGES_TABLE.'
+  WHERE id IN('.implode(',', array_unique($image_ids)).')
+;';
+    $images = simple_hash_from_query($query, 'id', 'file');
+    
     $inserts = array();
     
-    foreach ($image_ids as $image_id)
+    foreach ($images as $image_id => $file)
     {
       if ($this->isInSet($image_id)) continue;
+      if (!in_array(get_extension($file), $conf['batch_download']['allowed_ext'])) continue;
       
       $this->images[ $image_id ] = 0;
@@ -681,4 +690,14 @@
     return array_merge($set, $this->getNames());
   }
+  
+  /**
+   * delete
+   */
+  function delete()
+  {
+    $this->deleteLastArchive();
+    $this->clearImages();
+    pwg_query('DELETE FROM '.BATCH_DOWNLOAD_TSETS.' WHERE id = '.$this->data['id'].';');
+  }
 }
 
Index: extensions/BatchDownloader/include/events.inc.php
===================================================================
--- extensions/BatchDownloader/include/events.inc.php	(revision 23167)
+++ extensions/BatchDownloader/include/events.inc.php	(revision 23280)
@@ -88,25 +88,36 @@
     {
       $BatchDownloader = new BatchDownloader('new', $page['items'], $set['type'], $set['id']);
-      $BatchDownloader->getEstimatedArchiveNumber();
       
-      // if we plan only one zip with less elements than 'max_elements', the download starts immediately
-      if (
-        $BatchDownloader->getParam('nb_images') <= $conf['batch_download']['max_elements']
-        and $BatchDownloader->getParam('nb_zip') == 1
-      )
+      if ($BatchDownloader->getParam('nb_images') != 0)
       {
-        $BatchDownloader->createNextArchive(true); // make sure we have only one zip, even if 'max_size' is exceeded
+        $BatchDownloader->getEstimatedArchiveNumber();
         
-        $u_download = get_root_url().BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$BatchDownloader->getParam('id').'&amp;zip=1';
-        
-        $null = null;
-        $template->block_footer_script(null, 'setTimeout("document.location.href = \''.$u_download.'\';", 1000);', $null, $null);
-        
-        array_push($page['infos'], sprintf(l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>'), $u_download));
+        // if we plan only one zip with less elements than 'max_elements', the download starts immediately
+        if (
+          $BatchDownloader->getParam('nb_images') <= $conf['batch_download']['max_elements']
+          and $BatchDownloader->getParam('nb_zip') == 1
+        )
+        {
+          $BatchDownloader->createNextArchive(true); // make sure we have only one zip, even if 'max_size' is exceeded
+          
+          $u_download = get_root_url().BATCH_DOWNLOAD_PATH . 'download.php?set_id='.$BatchDownloader->getParam('id').'&amp;zip=1';
+          
+          $null = null;
+          $template->block_footer_script(null, 'setTimeout("document.location.href = \''.$u_download.'\';", 1000);', $null, $null);
+          
+          $page['infos'][] = sprintf(l10n('The archive is downloading, if the download doesn\'t start automatically please <a href="%s">click here</a>'), $u_download);
+        }
+        // otherwise we go to summary page
+        else
+        {
+          redirect(add_url_params(BATCH_DOWNLOAD_PUBLIC . 'init_zip', array('set_id'=>$BatchDownloader->getParam('id'))));
+        }
       }
-      // oterwise we go to summary page
       else
       {
-        redirect(add_url_params(BATCH_DOWNLOAD_PUBLIC . 'init_zip', array('set_id'=>$BatchDownloader->getParam('id'))));
+        $BatchDownloader->delete();
+        unset($BatchDownloader);
+        
+        $page['errors'][] = sprintf(l10n('Sorry, there is nothing to download. Some files may have been excluded because of <i title="Authorized types are : %s">filetype restrictions</i>.'), implode(', ', $conf['batch_download']['allowed_ext']));
       }
     }
Index: extensions/BatchDownloader/language/en_UK/plugin.lang.php
===================================================================
--- extensions/BatchDownloader/language/en_UK/plugin.lang.php	(revision 23167)
+++ extensions/BatchDownloader/language/en_UK/plugin.lang.php	(revision 23280)
@@ -49,4 +49,5 @@
 $lang['What can be downloaded?'] = 'What can be downloaded?';
 $lang['No result'] = 'No result';
+$lang['Sorry, there is nothing to download. Some files may have been excluded because of <i title="Authorized types are : %s">filetype restrictions</i>.'] = 'Sorry, there is nothing to download. Some files may have been excluded because of <i title="Authorized types are : %s">filetype restrictions</i>.';
 
 ?>
Index: extensions/BatchDownloader/language/fr_FR/plugin.lang.php
===================================================================
--- extensions/BatchDownloader/language/fr_FR/plugin.lang.php	(revision 23167)
+++ extensions/BatchDownloader/language/fr_FR/plugin.lang.php	(revision 23280)
@@ -49,4 +49,5 @@
 $lang['What can be downloaded?'] = 'Qu\'est-ce qui peut être téléchargé ?';
 $lang['No result'] = 'Aucun résultat';
+$lang['Sorry, there is nothing to download. Some files may have been excluded because of <i title="Authorized types are : %s">filetype restrictions</i>.'] = 'Désolé, il n\'y a rien à télécharger. Certains fichiers ont peut-être été exclu à cause de <i title="Les types autorisés sont : %s">leur type</i>.';
 
 ?>
Index: extensions/BatchDownloader/main.inc.php
===================================================================
--- extensions/BatchDownloader/main.inc.php	(revision 23167)
+++ extensions/BatchDownloader/main.inc.php	(revision 23280)
@@ -4,5 +4,5 @@
 Version: auto
 Description: Allows users to download pictures sets in ZIP. Compatible with User Collections.
-Plugin URI: http://piwigo.org/ext/extension_view.php?eid=616
+Plugin URI: auto
 Author: Mistic
 Author URI: http://www.strangeplanet.fr
@@ -11,8 +11,9 @@
 /*
  * advanced config:
- * $conf['batch_download_max_elements']  max value of the elements slider (default 1000)
- * $conf['batch_download_max_size']      max value of the size slider (default 500)
- * $conf['batch_download_force_pclzip']  if true, force the usage of PclZip instead of ZipArchive
- * $conf['batch_download_direct']        if true, the download script will redirect to the zip instead of deliver it through PHP
+ * $conf['batch_download_max_elements']   max value of the elements slider (default 1000)
+ * $conf['batch_download_max_size']       max value of the size slider (default 500)
+ * $conf['batch_download_force_pclzip']   if true, force the usage of PclZip instead of ZipArchive
+ * $conf['batch_download_direct']         if true, the download script will redirect to the zip instead of deliver it through PHP
+ * $conf['batch_download_additional_ext'] array containing downloadable filetypes (case sensitive), default is $conf['picture_ext']
  */
 
@@ -91,4 +92,10 @@
   
   $conf['batch_download'] = unserialize($conf['batch_download']);
+  $conf['batch_download']['allowed_ext'] = $conf['picture_ext'];
+  if (!empty($conf['batch_download_additional_ext']))
+  {
+    $conf['batch_download']['allowed_ext'] = array_merge($conf['batch_download']['allowed_ext'], $conf['batch_download_additional_ext']);
+  }
+  
   load_language('plugin.lang', BATCH_DOWNLOAD_PATH);
 }
