aboutsummaryrefslogtreecommitdiffstats
path: root/themes/smartpocket/themeconf.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2013-12-29 21:23:57 +0000
committerrvelices <rv-github@modusoptimus.com>2013-12-29 21:23:57 +0000
commit8c6f57e5f651395a984a0094338d2b913175aeec (patch)
tree04235e145bc53972f935c725bc8c8ddfe6ef210c /themes/smartpocket/themeconf.inc.php
parentbf9641a17b8c47f0555bca3f27be81925315e6e9 (diff)
smart pocket new thumbnail display
git-svn-id: http://piwigo.org/svn/trunk@26349 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'themes/smartpocket/themeconf.inc.php')
-rw-r--r--themes/smartpocket/themeconf.inc.php50
1 files changed, 45 insertions, 5 deletions
diff --git a/themes/smartpocket/themeconf.inc.php b/themes/smartpocket/themeconf.inc.php
index 837fcc5b2..9fc9e614d 100644
--- a/themes/smartpocket/themeconf.inc.php
+++ b/themes/smartpocket/themeconf.inc.php
@@ -22,6 +22,49 @@ include(PHPWG_THEMES_PATH.'smartpocket/admin/upgrade.inc.php');
redirect(duplicate_index_url());
*/
+
+class SPThumbPicker
+{
+ var $candidates;
+ var $default;
+ var $height;
+
+ function init($height)
+ {
+ $this->candidates = array();
+ foreach( ImageStdParams::get_defined_type_map() as $params)
+ {
+ if ($params->max_height() < $height || $params->sizing->max_crop)
+ continue;
+ if ($params->max_height() > 3*$height)
+ break;
+ $this->candidates[] = $params;
+ }
+ $this->default = ImageStdParams::get_custom($height*3, $height, 1, 0, $height );
+ $this->height = $height;
+ }
+
+ function pick($src_image)
+ {
+ $ok = false;
+ foreach($this->candidates as $candidate)
+ {
+ $deriv = new DerivativeImage($candidate, $src_image);
+ $size = $deriv->get_size();
+ if ($size[1]>=$row_height-2)
+ {
+ $ok = true;
+ break;
+ }
+ }
+ if (!$ok)
+ {
+ $deriv = new DerivativeImage($this->default, $src_image);
+ }
+ return $deriv;
+ }
+}
+
//Retrive all pictures on thumbnails page
add_event_handler('loc_index_thumbnails_selection', 'sp_select_all_thumbnails');
@@ -30,7 +73,7 @@ function sp_select_all_thumbnails($selection)
global $page, $template;
$template->assign('page_selection', array_flip($selection));
-
+ $template->assign('thumb_picker', new SPThumbPicker() );
return $page['items'];
}
@@ -48,10 +91,7 @@ $type = IMG_LARGE;
if (!empty($_COOKIE['screen_size']))
{
$screen_size = explode('x', $_COOKIE['screen_size']);
- $derivative_params = new ImageStdParams;
- $derivative_params->load_from_db();
-
- foreach ($derivative_params->get_all_type_map() as $type => $map)
+ foreach (ImageStdParams::get_all_type_map() as $type => $map)
{
if (max($map->sizing->ideal_size) >= max($screen_size) and min($map->sizing->ideal_size) >= min($screen_size))
break;