From c3b748ecbfd1a359f6e95e7fd691ac5c11c3c4de Mon Sep 17 00:00:00 2001 From: plegall Date: Mon, 7 Dec 2015 10:54:18 +0100 Subject: 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 --- picture.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'picture.php') 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); } -- cgit v1.2.3 From 0f8d85491f656440e7cc66ecca70f7af8dff0022 Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 17 Dec 2015 14:08:53 +0100 Subject: feature #379, multiple format, hide formats when disabled --- picture.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'picture.php') diff --git a/picture.php b/picture.php index a6c6defb7..f2dfecf0e 100644 --- a/picture.php +++ b/picture.php @@ -663,25 +663,28 @@ if ($conf['picture_download_icon'] and !empty($picture['current']['download_url' { $template->append('current', array('U_DOWNLOAD' => $picture['current']['download_url']), true); - $query = ' + if ($conf['enable_formats']) + { + $query = ' SELECT * FROM '.IMAGE_FORMAT_TABLE.' WHERE image_id = '.$picture['current']['id'].' ;'; - $formats = query2array($query); + $formats = query2array($query); - if (!empty($formats)) - { - foreach ($formats as &$format) + if (!empty($formats)) { - $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); + 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); + $template->append('current', array('formats' => $formats), true); + } } -- cgit v1.2.3 From 89bc74b3f30e169ab51e5b2728767f02a94a991c Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 20 Dec 2015 15:44:01 +0100 Subject: feature #379, multiple format, labels Ability to customize, with $lang['format CR2'] = 'RAW Canon' (in LocalFiles Editor) for example --- picture.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'picture.php') diff --git a/picture.php b/picture.php index f2dfecf0e..093e4b271 100644 --- a/picture.php +++ b/picture.php @@ -679,6 +679,13 @@ SELECT * $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['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); } } -- cgit v1.2.3 From 11f37b24b48ed9307ecdb2ac19f5809876d9227a Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 20 Dec 2015 17:49:12 +0100 Subject: feature #379, multiple format, no browser cache No need random string in URL to avoid browser cache, coding tip by @modus75 --- picture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'picture.php') diff --git a/picture.php b/picture.php index 093e4b271..75b7cdaf2 100644 --- a/picture.php +++ b/picture.php @@ -677,7 +677,7 @@ SELECT * 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['download_url'].= '&download'; $format['label'] = strtoupper($format['ext']); $lang_key = 'format '.strtoupper($format['ext']); -- cgit v1.2.3 From e439de1612eb471571c5a1503fba7f6531a90c08 Mon Sep 17 00:00:00 2001 From: plegall Date: Tue, 22 Dec 2015 19:04:00 +0100 Subject: feature #379, multiple format, consider the original as a format --- picture.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'picture.php') diff --git a/picture.php b/picture.php index 75b7cdaf2..d88e6e262 100644 --- a/picture.php +++ b/picture.php @@ -674,10 +674,23 @@ SELECT * if (!empty($formats)) { + // 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) { - $format['download_url'] = 'action.php?format='.$format['format_id']; - $format['download_url'].= '&download'; + 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']); -- cgit v1.2.3 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(-) (limited to 'picture.php') 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