Index: /extensions/pdf2tab/include/constants.inc.php
===================================================================
--- /extensions/pdf2tab/include/constants.inc.php	(revision 19662)
+++ /extensions/pdf2tab/include/constants.inc.php	(revision 19662)
@@ -0,0 +1,14 @@
+<?php
+$supported_extensions = array(
+							"pdf",
+							"docx",
+							"doc",
+							"odt",
+							"xlsx",
+							"xls",
+							"ods",
+							"pptx",
+							"ppt",
+							"odp",
+						);
+?>
Index: /extensions/pdf2tab/include/index.php
===================================================================
--- /extensions/pdf2tab/include/index.php	(revision 19662)
+++ /extensions/pdf2tab/include/index.php	(revision 19662)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2010 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/pdf2tab/main.inc.php
===================================================================
--- /extensions/pdf2tab/main.inc.php	(revision 19661)
+++ /extensions/pdf2tab/main.inc.php	(revision 19662)
@@ -11,4 +11,5 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
+define('PDF2TAB_ABSOLUTE_PATH' , dirname(__FILE__).'/');
 define('PDF2TAB_DIR' , basename(dirname(__FILE__)));
 define('PDF2TAB_PATH' , PHPWG_PLUGINS_PATH.PDF2TAB_DIR.'/');
@@ -18,5 +19,5 @@
  * +-----------------------------------------------------------------------+ */
 	
-include_once(PDF2TAB_PATH.'thumbnails.php');
-include_once(PDF2TAB_PATH.'picture.php');
+include_once(PDF2TAB_PATH.'include/thumbnails.inc.php');
+include_once(PDF2TAB_PATH.'include/picture.inc.php');
 ?>
Index: /extensions/pdf2tab/picture.php
===================================================================
--- /extensions/pdf2tab/picture.php	(revision 19661)
+++ /extensions/pdf2tab/picture.php	(revision 19662)
@@ -1,15 +1,29 @@
 <?php
-add_event_handler('render_element_content','pdf2tab_add_tag_picture',EVENT_HANDLER_PRIORITY_NEUTRAL+10,2);
+add_event_handler('render_element_content','pdf2tab_add_links_picture',EVENT_HANDLER_PRIORITY_NEUTRAL+10,2);
 
 load_language('plugin.lang', PDF2TAB_PATH);
 
-function pdf2tab_add_tag_picture($content, $element_info) {
-	if (strrchr($element_info['file'], ".") == ".pdf") {
-		preg_match('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i',$content,$match);
-		
-		$content = str_replace($match[0],'<a href="'.$element_info['element_url'].'" target="_blank" title="'.l10n('Open the file in a new tab').'">'.$match[0].'</a>',$content);
+function pdf2tab_add_links_picture($content, $element_info) {
+	include_once('include/constants.inc.php');
+
+	if (in_array(strtolower(substr(strrchr($element_info['file'], "."),1)), $supported_extensions)) {
+		$content = pdf2tab_add_link_image($content, $element_info);
+		$content = pdf2tab_add_link_beside_image($content, $element_info);
 	}
 	
 	return $content;
 }
+
+function pdf2tab_add_link_image($content, $element_info) {
+	preg_match('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i',$content,$match);
+	$content = str_replace($match[0],'<a href="'.$element_info['element_url'].'" target="_blank" title="'.l10n('Open the file in a new tab').'">'.$match[0].'</a>',$content);
+	
+	return $content;
+}
+
+function pdf2tab_add_link_beside_image($content, $element_info) {
+	$content .= '<p class="imageComment"><a href="'.$element_info['element_url'].'" target="_blank" title="'.l10n('Open the file in a new tab').'">'.l10n('Open the file in a new tab').'</a>';
+	
+	return $content;
+}
 ?>
Index: tensions/pdf2tab/template/pdf2tab_thumbnails.tpl
===================================================================
--- /extensions/pdf2tab/template/pdf2tab_thumbnails.tpl	(revision 19661)
+++ 	(revision )
@@ -1,24 +1,0 @@
-{html_head}
-{literal}
-<script type="text/javascript">
-	//Add a link to the thumbnail
-	function pdf2tab_link() {
-		$("img[pdf2tab$=pdf]").closest('a').attr("target","_blank");
-{/literal}
-		$("img[pdf2tab$=pdf]").attr("title","{'Open the file in a new tab'|@translate}");
-{literal}
-		$("img[pdf2tab$=pdf]").closest('a').attr("href",$("img[pdf2tab$=pdf]").attr("pdf2tab"));
-	}
-  
-	//When the document has finiched to load
-	jQuery(document).ready(function(){
-		pdf2tab_link();
-	});
-  
-	//Allow pdf2tab to work with RV Thumb Scroller 
-	jQuery(window).bind("RVTS_loaded", function(){
-		pdf2tab_link();
-	});
-</script>
-{/literal}
-{/html_head}
Index: /extensions/pdf2tab/template/thumbnails.tpl
===================================================================
--- /extensions/pdf2tab/template/thumbnails.tpl	(revision 19662)
+++ /extensions/pdf2tab/template/thumbnails.tpl	(revision 19662)
@@ -0,0 +1,41 @@
+{combine_script id="jquery" load="header"}
+{html_head}
+{literal}
+<script type="text/javascript">
+	//Add a link to the thumbnail
+	function pdf2tab_link() {
+		$("img[class=thumbnail]").each(function() {
+			var filename_array = $(this).attr("pdf2tab").split(".");
+			var filename_extension = filename_array[filename_array.length-1].toLowerCase();
+			
+{/literal}
+			var pdf2tab_supported_extensions = new Array();
+			{foreach from=$pdf2tab_supported_extensions item=extension name=loop}
+				pdf2tab_supported_extensions[{$smarty.foreach.loop.index}] = "{$extension}";
+			{/foreach}
+{literal}
+			if(jQuery.inArray(filename_extension, pdf2tab_supported_extensions) != -1)
+			{
+				$(this).closest('a').attr({
+					target: "_blank",
+					href: $(this).attr("pdf2tab")
+				});
+{/literal}
+				$(this).attr("title","{'Open the file in a new tab'|@translate}");
+{literal}
+			}			
+		});
+	}
+  
+	//When the document has finiched to load
+	jQuery(document).ready(function(){
+		pdf2tab_link();
+	});
+  
+	//Allow pdf2tab to work with RV Thumb Scroller 
+	jQuery(window).bind("RVTS_loaded", function(){
+		pdf2tab_link();
+	});
+</script>
+{/literal}
+{/html_head}
Index: /extensions/pdf2tab/thumbnails.php
===================================================================
--- /extensions/pdf2tab/thumbnails.php	(revision 19661)
+++ /extensions/pdf2tab/thumbnails.php	(revision 19662)
@@ -6,8 +6,10 @@
 function pdf2tab_thumbnails($tpl_thumbnails_var) {
 	global $template;
-
+	include_once('include/constants.inc.php');
+	
 	$template->set_prefilter('index_thumbnails', 'pdf2tab_add_tag_thumbnails');
 	
-	$template->set_filename('pdf2tab_template_thumbnails', dirname(__FILE__).'/template/pdf2tab_thumbnails.tpl');
+	$template->assign('pdf2tab_supported_extensions', $supported_extensions);
+	$template->set_filename('pdf2tab_template_thumbnails', PDF2TAB_ABSOLUTE_PATH.'template/thumbnails.tpl');
 	$template->concat('PLUGIN_INDEX_CONTENT_END', $template->parse('pdf2tab_template_thumbnails', true));
 	
