Changeset 12797 for trunk/picture.php


Ignore:
Timestamp:
Dec 27, 2011, 9:26:49 PM (12 years ago)
Author:
rvelices
Message:

feature 2541 multisize

  • nicer presentation on picture.php
  • added a maintenance purge derivatives action
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/picture.php

    r12796 r12797  
    475475    $i = 'previous';
    476476  }
    477   else if (isset($page['next_item']) and $row['id'] == $page['next_item'])
     477  elseif (isset($page['next_item']) and $row['id'] == $page['next_item'])
    478478  {
    479479    $i = 'next';
    480480  }
    481   else if (isset($page['first_item']) and $row['id'] == $page['first_item'])
     481  elseif (isset($page['first_item']) and $row['id'] == $page['first_item'])
    482482  {
    483483    $i = 'first';
    484484  }
    485   else if (isset($page['last_item']) and $row['id'] == $page['last_item'])
     485  elseif (isset($page['last_item']) and $row['id'] == $page['last_item'])
    486486  {
    487487    $i = 'last';
     
    492492  }
    493493
    494   $picture[$i] = $row;
    495 
    496   $picture[$i]['is_picture'] = false;
    497   if (in_array(get_extension($row['file']), $conf['picture_ext']))
    498   {
    499     $picture[$i]['is_picture'] = true;
    500   }
    501 
    502   $picture[$i]['derivatives'] = DerivativeImage::get_all($row);
    503   $picture[$i]['src_image'] = $picture[$i]['derivatives'][IMG_THUMB]->src_image;
    504   $picture[$i]['thumbnail'] = $picture[$i]['derivatives'][IMG_THUMB]->get_url();
     494
     495
     496  $row['derivatives'] = DerivativeImage::get_all($row);
     497  $row['src_image'] = $row['derivatives'][IMG_THUMB]->src_image;
    505498 
    506499  // ------ build element_path and element_url
    507   $picture[$i]['element_path'] = get_element_path($picture[$i]);
    508   $picture[$i]['element_url'] = get_element_url($picture[$i]);
    509 
    510   // ------ build image_path and image_url
    511   if ($i=='current' or $i=='next')
    512   {
    513     $picture[$i]['image_path'] = get_image_path( $picture[$i] );
    514     $picture[$i]['image_url'] = get_image_url( $picture[$i] );
    515   }
     500  $row['element_path'] = get_element_path($row);
     501  $row['element_url'] = get_element_url($row);
    516502
    517503  if ($i=='current')
    518504  {
    519     if ( $picture[$i]['is_picture'] )
     505    if ( $row['src_image']->is_original() )
    520506    {
    521507      if ( $user['enabled_high']=='true' )
    522508      {
    523         $picture[$i]['download_url'] = get_download_url('e',$picture[$i]);
     509        $row['download_url'] = get_download_url('e',$row);
    524510      }
    525511    }
    526512    else
    527513    { // not a pic - need download link
    528       $picture[$i]['download_url'] = get_download_url('e',$picture[$i]);
    529     }
    530   }
    531 
    532 
    533   if ( !empty( $row['name'] ) )
    534   {
    535     $picture[$i]['name'] = $row['name'];
    536   }
    537   else
    538   {
    539     $file_wo_ext = get_filename_wo_extension($row['file']);
    540     $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext);
    541   }
    542 
    543   $picture[$i]['name'] = trigger_event('render_element_description', $picture[$i]['name']);
    544 
    545   $picture[$i]['url'] = duplicate_picture_url(
     514      $row['download_url'] = $row['element_url'];
     515    }
     516  }
     517
     518  $row['url'] = duplicate_picture_url(
    546519    array(
    547520      'image_id' => $row['id'],
     
    553526    );
    554527
     528  $picture[$i] = $row;
     529
     530  if ( !empty( $row['name'] ) )
     531  {
     532    $picture[$i]['name'] = $row['name'];
     533  }
     534  else
     535  {
     536    $file_wo_ext = get_filename_wo_extension($row['file']);
     537    $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext);
     538  }
     539
     540  $picture[$i]['name'] = trigger_event('render_element_description', $picture[$i]['name']);
     541
    555542  if ('previous'==$i and $page['previous_item']==$page['first_item'])
    556543  {
     
    560547  {
    561548    $picture['last'] = $picture[$i];
    562   }
    563 }
    564 
    565 // calculation of width and height for the current picture
    566 if (empty($picture['current']['width']))
    567 {
    568   $taille_image = @getimagesize($picture['current']['image_path']);
    569   if ($taille_image!==false)
    570   {
    571     $picture['current']['width'] = $taille_image[0];
    572     $picture['current']['height']= $taille_image[1];
    573549  }
    574550}
     
    638614  (
    639615    ($conf['show_exif'] or $conf['show_iptc'])
    640     and isset($picture['current']['image_path'])
     616    and !$picture['current']['src_image']->is_mimetype()
    641617    ),
    642   $picture['current']['path']
     618  $picture['current']
    643619  );
    644620
     
    653629// allow plugins to change what we computed before passing data to template
    654630$picture = trigger_event('picture_pictures_data', $picture);
    655 
    656 
    657 if (isset($picture['next']['image_url'])
    658     and $picture['next']['is_picture']
    659     and strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome/') === false)
    660 {
    661   $template->assign('U_PREFETCH', $picture['next']['image_url'] );
    662 }
    663631
    664632//------------------------------------------------------- navigation management
     
    673641        array(
    674642          'TITLE' => $picture[$which_image]['name'],
    675           'THUMB_SRC' => $picture[$which_image]['thumbnail'],
     643          'THUMB_SRC' => $picture[$which_image]['derivatives'][IMG_THUMB]->get_url(),
    676644          // Params slideshow was transmit to navigation buttons
    677645          'U_IMG' =>
     
    889857
    890858// size in pixels
    891 if ($picture['current']['is_picture'] and isset($picture['current']['width']) )
     859if ($picture['current']['src_image']->is_original() and isset($picture['current']['width']) )
    892860{
    893861  $infos['INFO_DIMENSIONS'] =
     
    981949$template->assign( 'ELEMENT_CONTENT', $element_content );
    982950
     951if (isset($picture['next'])
     952    and $picture['next']['src_image']->is_original()
     953    and strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome/') === false)
     954{
     955  $template->assign('U_PREFETCH', $picture['next']['derivatives'][pwg_get_session_var('picture_deriv', IMG_LARGE)]->get_url() );
     956}
     957
     958
    983959// +-----------------------------------------------------------------------+
    984960// |                               sub pages                               |
Note: See TracChangeset for help on using the changeset viewer.