Changeset 12796 for trunk/picture.php


Ignore:
Timestamp:
Dec 27, 2011, 6:26:44 AM (12 years ago)
Author:
rvelices
Message:

feature 2541 multisize

  • core implementation + usage on most public/admin pages
  • still to do: sync process, upload, gui/persistence for size parameters, migration script, center of interest ...
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/picture.php

    r12767 r12796  
    2222// +-----------------------------------------------------------------------+
    2323
    24 define('PHPWG_ROOT_PATH','./');
     24define('PHPWG_ROOT_PATH','');
    2525include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
    2626include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
     
    154154    return $content;
    155155  }
    156   if (!isset($element_info['image_url']))
    157   { // nothing to do
    158     return $content;
     156
     157  if (isset($_COOKIE['picture_deriv']))
     158  {
     159    pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']);
     160    setcookie('picture_deriv', false, 0);
     161  }
     162  $deriv_type = pwg_get_session_var('picture_deriv', IMG_LARGE);
     163  $selected_derivative = $element_info['derivatives'][$deriv_type];
     164
     165  $available_derivatives = array();
     166  $added = array();
     167  foreach($element_info['derivatives'] as $type => $derivative)
     168  {
     169    $url = $derivative->get_url();
     170    if (isset($added[$url]))
     171      continue;
     172    $added[$url] = 1;
     173    $available_derivatives[] = $type;
    159174  }
    160175
    161176  global $user, $page, $template;
     177 
     178  $template->append('current', array(
     179      'selected_derivative' => $selected_derivative,
     180      'available_derivative_types' => $available_derivatives,
     181    ), true);
     182
    162183
    163184  $template->set_filenames(
     
    165186    );
    166187
    167   if ( !$page['slideshow'] and isset($element_info['high_url']) )
    168   {
    169     $uuid = uniqid(rand());
    170     $template->assign(
    171       'high',
    172       array(
    173         'U_HIGH' => $element_info['high_url'],
    174         'UUID'   => $uuid,
    175         )
    176       );
    177   }
    178188  $template->assign( array(
    179       'SRC_IMG' => $element_info['image_url'],
    180189      'ALT_IMG' => $element_info['file'],
    181       'WIDTH_IMG' => @$element_info['scaled_width'],
    182       'HEIGHT_IMG' => @$element_info['scaled_height'],
    183190      )
    184191    );
     
    404411}
    405412
    406 // incrementation of the number of hits, we do this only if no action
     413//---------- incrementation of the number of hits, we do this only if no action
    407414if (trigger_event('allow_increment_element_hit_count', !isset($_POST['content']) ) )
    408415{
     
    493500  }
    494501
     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();
     505 
    495506  // ------ build element_path and element_url
    496507  $picture[$i]['element_path'] = get_element_path($picture[$i]);
     
    510521      if ( $user['enabled_high']=='true' )
    511522      {
    512         $hi_url=get_high_url($picture[$i]);
    513         if ( !empty($hi_url) )
    514         {
    515           $picture[$i]['high_url'] = $hi_url;
    516           $picture[$i]['download_url'] = get_download_url('h',$picture[$i]);
    517         }
     523        $picture[$i]['download_url'] = get_download_url('e',$picture[$i]);
    518524      }
    519525    }
     
    524530  }
    525531
    526   $picture[$i]['thumbnail'] = get_thumbnail_url($row);
    527532
    528533  if ( !empty( $row['name'] ) )
     
    567572    $picture['current']['height']= $taille_image[1];
    568573  }
    569 }
    570 
    571 if (!empty($picture['current']['width']))
    572 {
    573   list(
    574     $picture['current']['scaled_width'],
    575     $picture['current']['scaled_height']
    576     ) = get_picture_size(
    577       $picture['current']['width'],
    578       $picture['current']['height'],
    579       @$user['maxwidth'],
    580       @$user['maxheight']
    581     );
    582574}
    583575
     
    897889
    898890// size in pixels
    899 if ($picture['current']['is_picture'] AND $picture['current']['has_high'])
    900 {
    901   if (!empty($picture['current']['high_width']))
    902   {
    903     $infos['INFO_DIMENSIONS'] = $picture['current']['high_width'].'*'.$picture['current']['high_height'];
    904   }
    905   else if ($hi_size = @getimagesize($hi_url))
    906   {
    907     pwg_query('
    908       UPDATE ' . IMAGES_TABLE . '
    909       SET
    910         high_width = \'' . $hi_size[0].'\',
    911         high_height = \''.$hi_size[1] .'\'
    912       WHERE id = ' . $picture['current']['id'] . ';
    913     ');
    914    
    915     $infos['INFO_DIMENSIONS'] = $hi_size[0].'*'.$hi_size[1];
    916   }
    917 }
    918 else if ($picture['current']['is_picture'] and isset($picture['current']['width']) )
    919 {
    920   if ($picture['current']['scaled_width'] !== $picture['current']['width'] )
    921   {
    922     $infos['INFO_DIMENSIONS'] =
    923       '<a href="'.$picture['current']['image_url'].'" title="'.
    924       l10n('Original dimensions').'">'.
    925       $picture['current']['width'].'*'.$picture['current']['height'].'</a>';
    926   }
    927   else
    928   {
    929     $infos['INFO_DIMENSIONS'] =
    930       $picture['current']['width'].'*'.$picture['current']['height'];
    931   }
     891if ($picture['current']['is_picture'] and isset($picture['current']['width']) )
     892{
     893  $infos['INFO_DIMENSIONS'] =
     894    $picture['current']['width'].'*'.$picture['current']['height'];
    932895}
    933896
    934897// filesize
    935 if ($picture['current']['has_high'] and !empty($picture['current']['high_filesize']))
    936 {
    937   $infos['INFO_FILESIZE'] =
    938     sprintf(l10n('%d Kb'), $picture['current']['high_filesize']);
    939 }
    940 else if (!empty($picture['current']['filesize']))
     898if (!empty($picture['current']['filesize']))
    941899{
    942900  $infos['INFO_FILESIZE'] =
Note: See TracChangeset for help on using the changeset viewer.