Ignore:
Timestamp:
Oct 10, 2014, 10:24:01 AM (10 years ago)
Author:
JanisV
Message:

Code improvement: should be computed outside the loop only if thumb is needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Fotorama/main.inc.php

    r29974 r29976  
    151151      $type = $big_type;
    152152    }
     153
     154    if ($conf['Fotorama']['nav'] == 'thumbs' or $conf['Fotorama']['fullscreen_nav'] == 'thumbs')
     155    {
     156      $has_thumbs = true;
     157    }
     158    else
     159    {
     160      $has_thumbs = false;
     161    }
    153162   
     163    if ($has_thumbs)
     164    {
     165      if ($conf['Fotorama']['square_thumb'])
     166      {
     167        $thumb_params = ImageStdParams::get_custom($conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight'], 1, $conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight']);
     168      }
     169      else
     170      {
     171        $thumb_params = ImageStdParams::get_custom(9999, $conf['Fotorama']['thumbheight']);
     172      }
     173    }
     174
    154175    $picture = array();
    155176    while ($row = pwg_db_fetch_assoc($result))
    156177    {
    157178      $row['src_image'] = new SrcImage($row);
    158 //      $row['derivatives'] = DerivativeImage::get_all($row['src_image']);
    159179      $row['derivative'] = DerivativeImage::get_one($type, $row['src_image']);
    160180      if ($row['derivative'] == null)
     
    168188      }
    169189
    170       if ($conf['Fotorama']['square_thumb'])
    171       {
    172         $thumb_params = ImageStdParams::get_custom($conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight'], 1, $conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight']);
    173       }
    174       else
    175       {
    176         $thumb_params = ImageStdParams::get_custom(9999, $conf['Fotorama']['thumbheight']);
    177       }
    178       $row['derivative_thumb'] = new DerivativeImage($thumb_params, $row['src_image']);;
    179       if ($row['derivative_thumb'] == null)
    180       {
    181         $row['derivative_thumb'] = $row['src_image'];
     190      if ($has_thumbs)
     191      {
     192        $row['derivative_thumb'] = new DerivativeImage($thumb_params, $row['src_image']);;
     193        if ($row['derivative_thumb'] == null)
     194        {
     195          $row['derivative_thumb'] = $row['src_image'];
     196        }
    182197      }
    183198
     
    200215    $template->assign('current_rank', $page['current_rank']);
    201216    $template->assign(array('Fotorama' => $conf['Fotorama']));
     217    $template->assign('Fotorama_has_thumbs', $has_thumbs);
    202218    if (is_file('./themes/'.$user['theme'].'/template/fotorama.tpl'))
    203219    {
Note: See TracChangeset for help on using the changeset viewer.