Index: /extensions/delete_hd/delete_hd.tpl
===================================================================
--- /extensions/delete_hd/delete_hd.tpl	(revision 12662)
+++ /extensions/delete_hd/delete_hd.tpl	(revision 12662)
@@ -0,0 +1,1 @@
+<p><label><input type="checkbox" name="confirm_deletion" value="1"> {'Are you sure?'|@translate}</label></p>
Index: /extensions/delete_hd/language/en_UK/description.txt
===================================================================
--- /extensions/delete_hd/language/en_UK/description.txt	(revision 12662)
+++ /extensions/delete_hd/language/en_UK/description.txt	(revision 12662)
@@ -0,0 +1,1 @@
+Delete the HD (high definition) version of any photo from the Batch Manager
Index: /extensions/delete_hd/language/en_UK/index.php
===================================================================
--- /extensions/delete_hd/language/en_UK/index.php	(revision 12662)
+++ /extensions/delete_hd/language/en_UK/index.php	(revision 12662)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/delete_hd/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/delete_hd/language/en_UK/plugin.lang.php	(revision 12662)
+++ /extensions/delete_hd/language/en_UK/plugin.lang.php	(revision 12662)
@@ -0,0 +1,5 @@
+<?php
+$lang['Delete High Definition Photos'] = 'Delete High Definition Photos';
+$lang['High definition photos were deleted'] = 'High definition photos were deleted';
+$lang['No high definition photo can be deleted'] = 'No high definition photo can be deleted';
+?>
Index: /extensions/delete_hd/language/fr_FR/description.txt
===================================================================
--- /extensions/delete_hd/language/fr_FR/description.txt	(revision 12662)
+++ /extensions/delete_hd/language/fr_FR/description.txt	(revision 12662)
@@ -0,0 +1,1 @@
+Supprimer les version HD (haute définition) des photos depuis le gestionnaire par lot
Index: /extensions/delete_hd/language/fr_FR/index.php
===================================================================
--- /extensions/delete_hd/language/fr_FR/index.php	(revision 12662)
+++ /extensions/delete_hd/language/fr_FR/index.php	(revision 12662)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/delete_hd/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/delete_hd/language/fr_FR/plugin.lang.php	(revision 12662)
+++ /extensions/delete_hd/language/fr_FR/plugin.lang.php	(revision 12662)
@@ -0,0 +1,5 @@
+<?php
+$lang['Delete High Definition Photos'] = 'Supprimer les photos haute définition';
+$lang['High definition photos were deleted'] = 'Les photos haute définition ont été supprimées';
+$lang['No high definition photo can be deleted'] = 'Aucun photo haute définition n\'a pu être supprimée';
+?>
Index: /extensions/delete_hd/main.inc.php
===================================================================
--- /extensions/delete_hd/main.inc.php	(revision 12662)
+++ /extensions/delete_hd/main.inc.php	(revision 12662)
@@ -0,0 +1,129 @@
+<?php
+/*
+Plugin Name: Delete HD
+Version: auto
+Description: delete the HD (high definition) version of any photo from the Batch Manager
+Plugin URI: http://piwigo.org/ext/extension_view.php?eid=590
+Author: plg (Pierrick Le Gall)
+Author URI: http://le-gall.net/pierrick
+*/
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+add_event_handler('loc_begin_element_set_global', 'delete_hd_set_template_data');
+add_event_handler('element_set_global_action', 'delete_hd_element_action', 50, 2);
+
+function delete_hd_set_template_data()
+{
+  global $template,$lang;
+  
+  load_language('plugin.lang', dirname(__FILE__).'/');
+  
+  $template->set_filename('delete_hd', realpath(dirname(__FILE__).'/delete_hd.tpl'));
+  
+  $template->append(
+    'element_set_global_plugins_actions',
+    array(
+      'ID' => 'delete_hd',
+      'NAME' => l10n('Delete High Definition Photos'),
+      'CONTENT' => $template->parse('delete_hd', true))
+    );
+}
+
+function delete_hd_element_action($action, $collection)
+{
+  global $template, $page;
+
+  if ('delete_hd' == $action)
+  {
+    if (isset($_POST['confirm_deletion']) and 1 == $_POST['confirm_deletion'])
+    {
+      $deleted_ids = delete_hd_files($collection);
+
+      if (count($deleted_ids) > 0)
+      {
+        array_push($page['infos'], l10n('High definition photos were deleted'));
+      }
+      else
+      {
+        array_push($page['errors'], l10n('No high definition photo can be deleted'));
+      }
+    }
+    else
+    {
+      array_push($page['errors'], l10n('You need to confirm deletion'));
+    }
+
+  }
+}
+
+// Deletes all HD files (on disk) related to given image ids
+// @return image ids where HD files are deleted successfully
+//
+// code based on admin function delete_element_files
+function delete_hd_files($ids)
+{
+  if (count($ids) == 0)
+  {
+    return array();;
+  }
+
+  include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
+  
+  $new_ids = array();
+
+  $query = '
+SELECT
+    id,
+    path,
+    has_high
+  FROM '.IMAGES_TABLE.'
+  WHERE id IN ('.implode(',', $ids).')
+;';
+  $result = pwg_query($query);
+  while ($row = pwg_db_fetch_assoc($result))
+  {
+    if (url_is_remote($row['path']))
+    {
+      continue;
+    }
+    
+    $files = array();
+    
+    if (!empty($row['has_high']) and get_boolean($row['has_high']))
+    {
+      $files[] = get_high_path($row);
+    }
+    
+    $ok = true;
+    foreach ($files as $path)
+    {
+      if (is_file($path) and !unlink($path))
+      {
+        $ok = false;
+        trigger_error('"'.$path.'" cannot be removed', E_USER_WARNING);
+        break;
+      }
+    }
+    
+    if ($ok)
+    {
+      $new_ids[] += $row['id'];
+    }
+  }
+
+  if (count($new_ids) > 0)
+  {
+    $query = '
+UPDATE '.IMAGES_TABLE.'
+  SET has_high = NULL,
+    high_filesize = NULL,
+    high_width = NULL,
+    high_height = NULL
+  WHERE id IN ('.implode(',', $new_ids).')
+;';
+    pwg_query($query);
+  }
+  
+  return $new_ids;
+}
+?>
