diff options
author | plegall <plg@piwigo.org> | 2015-12-30 16:08:54 +0100 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2015-12-30 16:08:54 +0100 |
commit | 6ba0148e646b2a193dc4111bb0a443d8c193e646 (patch) | |
tree | 382ecd35afae3522d07377df332f0ecfee1f5045 /picture.php | |
parent | f28420acfeb5d69e9ea39cd8d00cf9775d6cea54 (diff) | |
parent | 7b653c04d6cfb20366c3bb0e183a521b3c9d22d2 (diff) |
Merge branch 'feature/379-multiple-format'
Diffstat (limited to '')
-rw-r--r-- | picture.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/picture.php b/picture.php index 94c2b3ea3..d993fe3f2 100644 --- a/picture.php +++ b/picture.php @@ -662,6 +662,46 @@ 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); + + if ($conf['enable_formats']) + { + $query = ' +SELECT * + FROM '.IMAGE_FORMAT_TABLE.' + WHERE image_id = '.$picture['current']['id'].' +;'; + $formats = query2array($query); + + // let's add the original as a format among others. It will just have a + // specific download URL + array_unshift( + $formats, + array( + 'download_url' => $picture['current']['download_url'], + 'ext' => get_extension($picture['current']['file']), + 'filesize' => $picture['current']['filesize'], + ) + ); + + foreach ($formats as &$format) + { + if (!isset($format['download_url'])) + { + $format['download_url'] = 'action.php?format='.$format['format_id'].'&download'; + } + + $format['label'] = strtoupper($format['ext']); + $lang_key = 'format '.strtoupper($format['ext']); + if (isset($lang[$lang_key])) + { + $format['label'] = $lang[$lang_key]; + } + + $format['filesize'] = sprintf('%.1fMB', $format['filesize']/1024); + } + + $template->append('current', array('formats' => $formats), true); + } } |