aboutsummaryrefslogtreecommitdiffstats
path: root/picture.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2015-12-30 16:04:32 +0100
committerplegall <plg@piwigo.org>2015-12-30 16:04:32 +0100
commit7b653c04d6cfb20366c3bb0e183a521b3c9d22d2 (patch)
tree2f0153dbb7671630f5eb82fc46ea0ebae47a9ea0 /picture.php
parent99b1fd270445c719d85aacc9e3a8e7add1cd5106 (diff)
feature #379, multiple format, download original as format
If multiple format feature is enabled, always put the original file in the formats list.
Diffstat (limited to 'picture.php')
-rw-r--r--picture.php47
1 files 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'].'&amp;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'].'&amp;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);