Changeset 29976


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

Location:
extensions/Fotorama
Files:
2 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    {
  • extensions/Fotorama/template/fotorama-content.tpl

    r29942 r29976  
    2020  <a href="{$thumbnail.derivative->get_url()}"
    2121    data-full="{$thumbnail.derivative_big->get_url()}" data-url="{$thumbnail.url}" data-caption="{$thumbnail.TITLE}"
    22     {if $Fotorama.nav == 'thumbs' || $Fotorama.fullscreen_nav == 'thumbs'}data-thumb="{$thumbnail.derivative_thumb->get_url()}"{/if}>
    23     {assign var=thumb_size value=$thumbnail.derivative_thumb->get_size()}
    24     {if !$Fotorama.square_thumb}<img width="{$thumb_size[0]}" height="{$thumb_size[1]}">{/if}
     22    {if $Fotorama_has_thumbs}data-thumb="{$thumbnail.derivative_thumb->get_url()}"{/if}>
     23    {if $Fotorama_has_thumbs}
     24      {assign var=thumb_size value=$thumbnail.derivative_thumb->get_size()}
     25      {if !$Fotorama.square_thumb}<img width="{$thumb_size[0]}" height="{$thumb_size[1]}">{/if}
     26    {/if}
    2527  </a>
    2628{/foreach}
Note: See TracChangeset for help on using the changeset viewer.