Index: extensions/photo_update/admin.php
===================================================================
--- extensions/photo_update/admin.php	(revision 24622)
+++ extensions/photo_update/admin.php	(revision 24623)
@@ -69,18 +69,82 @@
   else
   {
-    add_uploaded_file(
-      $_FILES['photo_update']['tmp_name'],
-      $_FILES['photo_update']['name'],
-      null,
-      null,
-      $_GET['image_id']
-      );
-
-    $page['photo_update_refresh_thumbnail'] = true;
-
-    array_push(
-      $page['infos'],
-      l10n('The photo was updated')
-      );
+    $file_to_update = 'main';
+    if (isset($_POST['file_to_update']) and in_array($_POST['file_to_update'], array('main', 'representative')))
+    {
+      $file_to_update = $_POST['file_to_update'];
+    }
+
+    $image_id = $_GET['image_id'];
+      
+    $query = '
+SELECT
+    id, path, representative_ext
+  FROM '.IMAGES_TABLE.'
+  WHERE id = '.$image_id.'
+;';
+    $result = pwg_query($query);
+    $row = pwg_db_fetch_assoc($result);
+
+    if ('main' == $file_to_update)
+    {
+      add_uploaded_file(
+        $_FILES['photo_update']['tmp_name'],
+        $_FILES['photo_update']['name'],
+        null,
+        null,
+        $_GET['image_id']
+        );
+      
+      array_push(
+        $page['infos'],
+        l10n('The photo was updated')
+        );
+    }
+    
+    if ('representative' == $file_to_update)
+    {
+      $file_path = $row['path'];
+
+      // move the uploaded file to pwg_representative sub-directory
+      $representative_file_path = dirname($file_path).'/pwg_representative/';      
+      $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.';
+
+      $old_representative_file_path = $representative_file_path.$row['representative_ext'];
+
+      $representative_ext = get_extension($_FILES['photo_update']['name']);
+
+      // in case we replace a *.jpg by *.png we have to safely remove the
+      // *.jpg becase move_uploaded_file won't remove it
+      if ($representative_ext != $row['representative_ext'])
+      {
+        @unlink($representative_file_path.$row['representative_ext']);
+      }
+      
+      $representative_file_path.= $representative_ext;
+
+      prepare_directory(dirname($representative_file_path));
+
+      move_uploaded_file($_FILES['photo_update']['tmp_name'], $representative_file_path);
+
+      $file_infos = pwg_image_infos($representative_file_path);
+      
+      single_update(
+        IMAGES_TABLE,
+        array(
+          'representative_ext' => $representative_ext,
+          'width' => $file_infos['width'],
+          'height' => $file_infos['height'],
+          ),
+        array('id' => $image_id)
+        );
+      
+      array_push(
+        $page['infos'],
+        l10n('The representative picture was updated')
+        );
+    }
+
+    // force refresh of multiple sizes
+    delete_element_derivatives($row);
   }
 }
@@ -117,7 +181,13 @@
 $row = pwg_db_fetch_assoc(pwg_query($query));
 
+if (!in_array(get_extension($row['path']), $conf['picture_ext']) or !empty($row['representative_ext']))
+{
+  $template->assign('show_file_to_update', true);
+}
+
 $template->assign(
   array(
-    'TN_SRC' => DerivativeImage::thumb_url($row).(isset($_FILES['photo_update']) ? '?'.time() : ''),
+    'TN_SRC' => DerivativeImage::thumb_url($row),
+    'original_filename' => $row['file'],
     'TITLE' => render_element_name($row),
     )
Index: extensions/photo_update/admin.tpl
===================================================================
--- extensions/photo_update/admin.tpl	(revision 24622)
+++ extensions/photo_update/admin.tpl	(revision 24623)
@@ -5,9 +5,16 @@
   <table>
     <tr>
-      <td id="albumThumbnail">
+      <td id="albumThumbnail" style="vertical-align:top">
         <img src="{$TN_SRC}" alt="{'Thumbnail'|@translate}" class="Thumbnail">
       </td>
       <td style="vertical-align:top">
         <form id="photo_update" method="post" action="" enctype="multipart/form-data">
+{if isset($show_file_to_update)}
+          <p style="text-align:left; margin-top:0;">
+            <strong>{'File to update'|@translate}</strong><br>
+            <label><input type="radio" name="file_to_update" value="main"> {'main file'|@translate} ({$original_filename})</label>
+            <label><input type="radio" name="file_to_update" value="representative" checked="checked"> {'representative picture'|@translate}</label>
+          </p>
+{/if}
           <p style="text-align:left; margin-top:0;">
             <strong>{'Select a file'|@translate}</strong><br>
Index: extensions/photo_update/language/en_UK/plugin.lang.php
===================================================================
--- extensions/photo_update/language/en_UK/plugin.lang.php	(revision 24622)
+++ extensions/photo_update/language/en_UK/plugin.lang.php	(revision 24623)
@@ -3,3 +3,6 @@
 $lang['Photo Update'] = 'Photo Update';
 $lang['Update'] = 'Update';
+$lang['File to update'] = 'File to update';
+$lang['main file'] = 'main file';
+$lang['representative picture'] = 'representative picture';
 ?>
Index: extensions/photo_update/language/fr_FR/plugin.lang.php
===================================================================
--- extensions/photo_update/language/fr_FR/plugin.lang.php	(revision 24622)
+++ extensions/photo_update/language/fr_FR/plugin.lang.php	(revision 24623)
@@ -3,3 +3,6 @@
 $lang['Photo Update'] = 'Mise à jour de la photo';
 $lang['Update'] = 'Mettre à jour';
+$lang['File to update'] = 'Fichier à mettre à jour';
+$lang['main file'] = 'fichier principal';
+$lang['representative picture'] = 'image représentante';
 ?>
