From 7b653c04d6cfb20366c3bb0e183a521b3c9d22d2 Mon Sep 17 00:00:00 2001 From: plegall Date: Wed, 30 Dec 2015 16:04:32 +0100 Subject: feature #379, multiple format, download original as format If multiple format feature is enabled, always put the original file in the formats list. --- picture.php | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/picture.php b/picture.php index d88e6e262..d993fe3f2 100644 --- a/picture.php +++ b/picture.php @@ -671,36 +671,33 @@ SELECT * 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'], + ) + ); - if (!empty($formats)) + foreach ($formats as &$format) { - // 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'], - ) - ); + if (!isset($format['download_url'])) + { + $format['download_url'] = 'action.php?format='.$format['format_id'].'&download'; + } - foreach ($formats as &$format) + $format['label'] = strtoupper($format['ext']); + $lang_key = 'format '.strtoupper($format['ext']); + if (isset($lang[$lang_key])) { - 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); + $format['label'] = $lang[$lang_key]; } + + $format['filesize'] = sprintf('%.1fMB', $format['filesize']/1024); } $template->append('current', array('formats' => $formats), true); -- cgit v1.2.3