Ignore:
Timestamp:
Jan 17, 2012, 10:02:16 PM (12 years ago)
Author:
rvelices
Message:

feature 2548 multisize - implement delete_element_derivatives

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_upload.inc.php

    r12907 r12917  
    33// | Piwigo - a PHP based photo gallery                                    |
    44// +-----------------------------------------------------------------------+
    5 // | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
     5// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
    66// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
    77// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
     
    3737      'can_be_null' => false,
    3838      ),
    39  
     39
    4040    'original_resize_maxwidth' => array(
    4141      'default' => 2000,
     
    4646      'error_message' => l10n('The original maximum width must be a number between %d and %d'),
    4747      ),
    48  
     48
    4949    'original_resize_maxheight' => array(
    5050      'default' => 2000,
     
    5555      'error_message' => l10n('The original maximum height must be a number between %d and %d'),
    5656      ),
    57  
     57
    5858    'original_resize_quality' => array(
    5959      'default' => 95,
     
    113113      $max = $upload_form_config[$field]['max'];
    114114      $pattern = $upload_form_config[$field]['pattern'];
    115      
     115
    116116      if (preg_match($pattern, $value) and $value >= $min and $value <= $max)
    117117      {
     
    158158  //
    159159  // 3) register in database
    160  
     160
    161161  // TODO
    162162  // * check md5sum (already exists?)
    163  
     163
    164164  global $conf, $user;
    165165
     
    172172    $md5sum = md5_file($source_filepath);
    173173  }
    174  
     174
    175175  $file_path = null;
    176  
     176
    177177  if (isset($image_id))
    178178  {
     
    189189      $file_path = $row['path'];
    190190    }
    191    
     191
    192192    if (!isset($file_path))
    193193    {
     
    201201  {
    202202    // this photo is new
    203    
     203
    204204    // current date
    205205    list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    206206    list($year, $month, $day) = preg_split('/[^\d]/', $dbnow, 4);
    207  
     207
    208208    // upload directory hierarchy
    209209    $upload_dir = sprintf(
     
    251251    {
    252252      $need_resize = need_resize($file_path, $conf['original_resize_maxwidth'], $conf['original_resize_maxheight']);
    253      
     253
    254254      if ($need_resize)
    255255      {
    256256        $img = new pwg_image($file_path);
    257            
     257
    258258        $img->pwg_resize(
    259259          $file_path,
     
    264264          false
    265265          );
    266        
     266
    267267        $img->destroy();
    268268      }
     
    271271
    272272  $file_infos = pwg_image_infos($file_path);
    273  
     273
    274274  if (isset($image_id))
    275275  {
     
    282282      'added_by' => $user['id'],
    283283      );
    284    
     284
    285285    if (isset($level))
    286286    {
     
    293293      array('id' => $image_id)
    294294      );
    295 
    296     delete_element_derivatives($image_id);
    297295  }
    298296  else
     
    309307      'added_by' => $user['id'],
    310308      );
    311    
     309
    312310    if (isset($level))
    313311    {
     
    316314
    317315    single_insert(IMAGES_TABLE, $insert);
    318  
     316
    319317    $image_id = pwg_db_insert_id(IMAGES_TABLE);
    320318  }
     
    327325      );
    328326  }
    329  
     327
    330328  // update metadata from the uploaded file (exif/iptc)
    331329  if ($conf['use_exif'] and !function_exists('read_exif_data'))
     
    375373  // invert width and height.
    376374  list($width, $height) = getimagesize($image_filepath);
    377  
     375
    378376  if ($width > $max_width or $height > $max_height)
    379377  {
     
    388386  list($width, $height) = getimagesize($path);
    389387  $filesize = floor(filesize($path)/1024);
    390  
     388
    391389  return array(
    392390    'width'  => $width,
     
    434432    $size = convert_shorthand_notation_to_bytes($size);
    435433  }
    436  
     434
    437435  return $size;
    438436}
     
    442440  $suffix = substr($value, -1);
    443441  $multiply_by = null;
    444  
     442
    445443  if ('K' == $suffix)
    446444  {
     
    455453    $multiply_by = 1024*1024*1024;
    456454  }
    457  
     455
    458456  if (isset($multiply_by))
    459457  {
     
    500498    {
    501499      @chmod($conf['upload_dir'], 0777);
    502      
     500
    503501      if (!is_writable($conf['upload_dir']))
    504502      {
Note: See TracChangeset for help on using the changeset viewer.