diff options
author | plegall <plg@piwigo.org> | 2015-12-07 10:54:18 +0100 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2015-12-07 10:54:18 +0100 |
commit | c3b748ecbfd1a359f6e95e7fd691ac5c11c3c4de (patch) | |
tree | cd8710c9a1684fde5616f9332b8a4a90ce09348f /picture.php | |
parent | 8e098d502a8f0e413b9c085db27d6a62a6c0909f (diff) |
feature #379 multiple format, step 2: download formats
* if formats are available, replace the download link on picture.php by a switchBox with all formats
* register format in the history table for future statistics
Diffstat (limited to '')
-rw-r--r-- | picture.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/picture.php b/picture.php index 94c2b3ea3..a6c6defb7 100644 --- a/picture.php +++ b/picture.php @@ -662,6 +662,26 @@ foreach (array('first','previous','next','last', 'current') as $which_image) if ($conf['picture_download_icon'] and !empty($picture['current']['download_url'])) { $template->append('current', array('U_DOWNLOAD' => $picture['current']['download_url']), true); + + $query = ' +SELECT * + FROM '.IMAGE_FORMAT_TABLE.' + WHERE image_id = '.$picture['current']['id'].' +;'; + $formats = query2array($query); + + if (!empty($formats)) + { + foreach ($formats as &$format) + { + $format['download_url'] = 'action.php?format='.$format['format_id']; + $format['download_url'].= '&download='.substr(md5(time()), 0, 6); // a random string to avoid browser cache + + $format['filesize'] = sprintf('%.1fMB', $format['filesize']/1024); + } + } + + $template->append('current', array('formats' => $formats), true); } |