Ignore:
Timestamp:
Dec 29, 2013, 10:23:57 PM (10 years ago)
Author:
rvelices
Message:

smart pocket new thumbnail display

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/themes/smartpocket/themeconf.inc.php

    r24928 r26349  
    2323*/
    2424
     25
     26class SPThumbPicker
     27{
     28  var $candidates;
     29  var $default;
     30  var $height;
     31 
     32  function init($height)
     33  {
     34    $this->candidates = array();
     35    foreach( ImageStdParams::get_defined_type_map() as $params)
     36    {
     37      if ($params->max_height() < $height || $params->sizing->max_crop)
     38        continue;
     39      if ($params->max_height() > 3*$height)
     40        break;
     41      $this->candidates[] = $params;
     42    }
     43    $this->default = ImageStdParams::get_custom($height*3, $height, 1, 0, $height );
     44    $this->height = $height;
     45  }
     46 
     47  function pick($src_image)
     48  {
     49    $ok = false;
     50    foreach($this->candidates as $candidate)
     51    {
     52      $deriv = new DerivativeImage($candidate, $src_image);
     53      $size = $deriv->get_size();
     54      if ($size[1]>=$row_height-2)
     55      {
     56        $ok = true;
     57        break;
     58      }
     59    }
     60    if (!$ok)
     61    {
     62      $deriv = new DerivativeImage($this->default, $src_image);
     63    }
     64    return $deriv;
     65  }
     66}
     67
    2568//Retrive all pictures on thumbnails page
    2669add_event_handler('loc_index_thumbnails_selection', 'sp_select_all_thumbnails');
     
    3174
    3275  $template->assign('page_selection', array_flip($selection));
    33 
     76  $template->assign('thumb_picker', new SPThumbPicker() );
    3477  return $page['items'];
    3578}
     
    4992{
    5093  $screen_size = explode('x', $_COOKIE['screen_size']);
    51   $derivative_params = new ImageStdParams;
    52   $derivative_params->load_from_db();
    53 
    54   foreach ($derivative_params->get_all_type_map() as $type => $map)
     94  foreach (ImageStdParams::get_all_type_map() as $type => $map)
    5595  {
    5696    if (max($map->sizing->ideal_size) >= max($screen_size) and min($map->sizing->ideal_size) >= min($screen_size))
Note: See TracChangeset for help on using the changeset viewer.