Index: /extensions/DownloadSinceThumbnail/dst.css
===================================================================
--- /extensions/DownloadSinceThumbnail/dst.css	(revision 31376)
+++ /extensions/DownloadSinceThumbnail/dst.css	(revision 31376)
@@ -0,0 +1,7 @@
+.dowpic{
+  border:none;
+  position:relative;
+  top:25px;
+  left: 55px;
+  z-index:4;
+}
Index: /extensions/DownloadSinceThumbnail/dst.tpl
===================================================================
--- /extensions/DownloadSinceThumbnail/dst.tpl	(revision 31376)
+++ /extensions/DownloadSinceThumbnail/dst.tpl	(revision 31376)
@@ -0,0 +1,10 @@
+{footer_script}
+jQuery(document).ready(function(){
+jQuery('.dowpica').click(function(){
+    var id= $(this).data('id');
+    jQuery.post("plugins/DownloadSinceThumbnail/save_history.php", {
+        dsp_his: id,
+    });
+  });
+});
+{/footer_script}
Index: /extensions/DownloadSinceThumbnail/index.php
===================================================================
--- /extensions/DownloadSinceThumbnail/index.php	(revision 31376)
+++ /extensions/DownloadSinceThumbnail/index.php	(revision 31376)
@@ -0,0 +1,6 @@
+<?php
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
Index: /extensions/DownloadSinceThumbnail/language/en_UK/description.txt
===================================================================
--- /extensions/DownloadSinceThumbnail/language/en_UK/description.txt	(revision 31376)
+++ /extensions/DownloadSinceThumbnail/language/en_UK/description.txt	(revision 31376)
@@ -0,0 +1,1 @@
+Download since album page (thumbnail)
Index: /extensions/DownloadSinceThumbnail/language/en_UK/index.php
===================================================================
--- /extensions/DownloadSinceThumbnail/language/en_UK/index.php	(revision 31376)
+++ /extensions/DownloadSinceThumbnail/language/en_UK/index.php	(revision 31376)
@@ -0,0 +1,28 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Plugin Piwigo -                                     |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2015 SAS TEMMII                  http://temmii.org |
+// +-----------------------------------------------------------------------+
+// | 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/DownloadSinceThumbnail/language/index.php
===================================================================
--- /extensions/DownloadSinceThumbnail/language/index.php	(revision 31376)
+++ /extensions/DownloadSinceThumbnail/language/index.php	(revision 31376)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based photo gallery                                    |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2012 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/DownloadSinceThumbnail/main.inc.php
===================================================================
--- /extensions/DownloadSinceThumbnail/main.inc.php	(revision 31376)
+++ /extensions/DownloadSinceThumbnail/main.inc.php	(revision 31376)
@@ -0,0 +1,88 @@
+<?php
+/*
+Plugin Name: Download Since Thumbnail
+Version: 2.7.0
+Description: 
+Plugin URI: http://piwigo.org/ext/extension_view.php?eid=
+Author: TEMMII
+Author URI: http://temmii.com/
+*/
+
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
+
+global $conf, $prefixeTable;
+
+define('DST_ID',          basename(dirname(__FILE__)));
+define('DST_PATH',        PHPWG_PLUGINS_PATH . DST_ID . '/');
+
+add_event_handler('init', 'DST_init');
+add_event_handler('loc_end_index_thumbnails', 'DST_thumbnails_list', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2);
+
+
+function DST_init()
+{
+  if (mobile_theme())
+  {
+    return;
+  }
+  load_language('plugin.lang', DST_PATH);
+   
+}
+
+function DST_thumbnails_list($tpl_thumbnails_var, $pictures)
+{
+  if (is_a_guest()) return $tpl_thumbnails_var;
+
+  global $page, $template,$conf, $user;
+
+  $template->set_prefilter('index_thumbnails', 'DST_prefilter_thumbnails');
+  $template->set_filename('DST', realpath(DST_PATH.'dst.tpl'));
+  $template->append('head_elements',$template->parse('DST',true));
+
+  
+  // the content is different on collection edition page and no button on batch downloader set edition page
+  if (empty($pictures))
+  {
+    return $tpl_thumbnails_var;
+  }
+
+ // $image_ids = array_map(create_function('$i', 'return $i["id"];'), $pictures);
+
+  $query = '
+  SELECT enabled_high
+  FROM '.USER_INFOS_TABLE.'
+  WHERE user_id = \''.$user['id'].'\'
+  ;';
+  $result = pwg_query($query);
+  $row = pwg_db_fetch_assoc($result);
+  if($row['enabled_high']=='true'){
+	$template->assign('PLUG_DST', 'ok');
+  }
+  foreach ($tpl_thumbnails_var as &$thumbnail)
+  {
+    $thumbnail['dowpic']=DST_PATH.'save.png';
+  }
+  
+  $template->func_combine_css(array('id'=>'dst','path'=>DST_PATH.'dst.css'));
+  
+  return $tpl_thumbnails_var;
+}
+
+function DST_prefilter_thumbnails($content, &$smarty) {
+	global $template;
+
+	
+ $search = '#(<span class="wrap2">)#';
+ $replace = '$1
+  {strip}{if isset($PLUG_DST)}
+  <form method="post" >
+  <a href="{$thumbnail.path}" class="dowpica" data-id="{$thumbnail.id}" download="{$thumbnail.name}" title="{\'Download this file\'|@translate}" rel="nofollow">
+  <img class="dowpic" src="{$thumbnail.dowpic}" /></a>
+  </form>
+  {/if}{/strip}
+';
+
+  return preg_replace($search, $replace, $content);
+	
+}
+
Index: /extensions/DownloadSinceThumbnail/maintain.class.php
===================================================================
--- /extensions/DownloadSinceThumbnail/maintain.class.php	(revision 31376)
+++ /extensions/DownloadSinceThumbnail/maintain.class.php	(revision 31376)
@@ -0,0 +1,29 @@
+<?php
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
+
+class DownloadSinceThumbnail_maintain extends PluginMaintain
+{
+  private $installed = false;
+
+  function __construct($plugin_id){
+    parent::__construct($plugin_id);
+  }
+
+  function install($plugin_version, &$errors=array()){
+  }
+
+  function activate($plugin_version, &$errors=array()){
+  	$query = "ALTER TABLE ". HISTORY_TABLE ." CHANGE `image_type` `image_type` ENUM( 'picture', 'high', 'other', 'download' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
+	$result = pwg_query($query);
+  }
+
+  function update($old_version, $new_version, &$errors=array()){
+  }
+  
+  function deactivate(){
+  }
+
+  function uninstall(){
+  }
+}
+?>
Index: /extensions/DownloadSinceThumbnail/save_history.php
===================================================================
--- /extensions/DownloadSinceThumbnail/save_history.php	(revision 31376)
+++ /extensions/DownloadSinceThumbnail/save_history.php	(revision 31376)
@@ -0,0 +1,78 @@
+<?php
+
+
+define('PHPWG_ROOT_PATH','../../');
+include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
+include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
+
+check_status(ACCESS_GUEST);
+
+if (!isset($_POST['dsp_his']))
+{
+  die;
+}
+
+pwg_log($_POST['dsp_his'], 'download');
+/*
+
+$query = 'UPDATE '.IMAGES_TABLE.' SET hit=hit+1 WHERE id = '.$_POST['dsp_his'].';';
+pwg_query($query);
+
+$do_log = $conf['log'];
+if (is_admin())
+{
+  $do_log = $conf['history_admin'];
+}
+if (is_a_guest())
+{
+  $do_log = $conf['history_guest'];
+}
+
+if (!$do_log)
+{
+  exit();
+}
+
+if (!empty($_POST['section']))
+{
+  $page['section'] = pwg_db_real_escape_string($_POST['section']);
+}
+if (!empty($_POST['catid']))
+{
+  $page['category']['id'] = pwg_db_real_escape_string($_POST['catid']);
+}
+if ('tags'==@$page['section'] and !empty($_POST['tagids']))
+{
+  $tags_string = pwg_db_real_escape_string($_POST['tagids']);
+}
+
+  $query = '
+INSERT INTO '.HISTORY_TABLE.'
+  (
+    date,
+    time,
+    user_id,
+    IP,
+    section,
+    category_id,
+    image_id,
+    image_type,
+    tag_ids,
+    lightbox
+  )
+  VALUES
+  (
+    CURDATE(),
+    CURTIME(),
+    '.$user['id'].',
+    \''.$_SERVER['REMOTE_ADDR'].'\',
+    '.(isset($page['section']) ? "'".$page['section']."'" : 'NULL').',
+    '.(isset($page['category']['id']) ? $page['category']['id'] : 'NULL').',
+    '.$image_id.',
+    "picture",
+    '.(isset($tags_string) ? "'".$tags_string."'" : 'NULL').',
+    "true"
+  )
+;';
+
+pwg_query($query);*/
