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/include/ws_functions.inc.php

    r12749 r12796  
    147147function ws_std_get_urls($image_row)
    148148{
    149   $ret = array(
    150     'tn_url' => get_thumbnail_url($image_row),
    151     'element_url' => get_element_url($image_row)
    152   );
     149  $ret = array();
    153150  global $user;
    154   if ($user['enabled_high'] and $image_row['has_high'] )
    155   {
    156     $ret['high_url'] = get_high_url($image_row);
    157   }
     151  if ($user['enabled_high'])
     152  {
     153    $ret['element_url'] = get_element_url($image_row);
     154  }
     155 
     156  $derivatives = DerivativeImage::get_all($image_row);
     157  $derivatives_arr = array();
     158  foreach($derivatives as $type=>$derivative)
     159  {
     160    $size = $derivative->get_size();
     161    $size != null or $size=array(null,null);
     162    $derivatives_arr[$type] = array('url' => $derivative->get_url(), 'width'=>$size[0], 'height'=>$size[1] );
     163  }
     164  $ret['derivatives'] = $derivatives_arr;;
    158165  return $ret;
    159166}
     
    166173{
    167174  return array(
    168     'id','tn_url','element_url','high_url', 'file','width','height','hit','date_available','date_creation'
     175    'id','element_url', 'file','width','height','hit','date_available','date_creation'
    169176    );
    170177}
     
    621628
    622629    $query = '
    623 SELECT id, path, tn_ext, level
     630SELECT id, path, representative_ext, level
    624631  FROM '.IMAGES_TABLE.'
    625632  WHERE id IN ('.implode(',', $image_ids).')
     
    630637      if ($row['level'] <= $user['level'])
    631638      {
    632         $thumbnail_src_of[$row['id']] = get_thumbnail_url($row);
     639        $thumbnail_src_of[$row['id']] = DerivativeImage::thumb_url($row);
    633640      }
    634641      else
     
    669676    {
    670677      $query = '
    671 SELECT id, path, tn_ext
     678SELECT id, path, representative_ext
    672679  FROM '.IMAGES_TABLE.'
    673680  WHERE id IN ('.implode(',', $new_image_ids).')
     
    676683      while ($row = pwg_db_fetch_assoc($result))
    677684      {
    678         $thumbnail_src_of[$row['id']] = get_thumbnail_url($row);
     685        $thumbnail_src_of[$row['id']] = DerivativeImage::thumb_url($row);
    679686      }
    680687    }
     
    13711378  if (!is_dir($upload_dir)) {
    13721379    umask(0000);
    1373     $recursive = true;
    1374     if (!@mkdir($upload_dir, 0777, $recursive))
     1380    if (!@mkdir($upload_dir, 0777, true))
    13751381    {
    13761382      return new PwgError(500, 'error during buffer directory creation');
     
    14251431    if (is_file($output_filepath))
    14261432    {
    1427       new PwgError(500, '[merge_chunks] error while trying to remove existing '.$output_filepath);
    1428       exit();
     1433      return new PwgError(500, '[merge_chunks] error while trying to remove existing '.$output_filepath);
    14291434    }
    14301435  }
     
    14651470    if (!file_put_contents($output_filepath, $string, FILE_APPEND))
    14661471    {
    1467       new PwgError(500, '[merge_chunks] error while writting chunks for '.$output_filepath);
    1468       exit();
     1472      return new PwgError(500, '[merge_chunks] error while writting chunks for '.$output_filepath);
    14691473    }
    14701474
     
    15011505    if (!@mkdir($upload_dir, 0777, $recursive))
    15021506    {
    1503       new PwgError(500, '[add_file] error during '.$type.' directory creation');
    1504       exit();
     1507      return new PwgError(500, '[add_file] error during '.$type.' directory creation');
    15051508    }
    15061509  }
     
    15131516    if (!is_writable($upload_dir))
    15141517    {
    1515       new PwgError(500, '[add_file] '.$type.' directory has no write access');
    1516       exit();
     1518      return new PwgError(500, '[add_file] '.$type.' directory has no write access');
    15171519    }
    15181520  }
     
    15261528  // check dumped thumbnail md5
    15271529  $dumped_md5 = md5_file($file_path);
    1528   if ($dumped_md5 != $file_sum) {
    1529     new PwgError(500, '[add_file] '.$type.' transfer failed');
    1530     exit();
     1530  if ($dumped_md5 != $file_sum)
     1531  {
     1532    return new PwgError(500, '[add_file] '.$type.' transfer failed');
    15311533  }
    15321534
     
    24522454      else
    24532455      {
    2454         new PwgError(
     2456        return new PwgError(
    24552457          500,
    24562458          '[ws_images_setInfo]'
     
    24582460          .', possible values are {fill_if_empty, replace}.'
    24592461          );
    2460         exit();
    24612462      }
    24622463    }
     
    24672468    if (!empty($image_row['storage_category_id']))
    24682469    {
    2469       new PwgError(500, '[ws_images_setInfo] updating "file" is forbidden on photos added by synchronization');
    2470       exit();
     2470      return new PwgError(500, '[ws_images_setInfo] updating "file" is forbidden on photos added by synchronization');
    24712471    }
    24722472
     
    25182518    else
    25192519    {
    2520       new PwgError(
     2520      return new PwgError(
    25212521        500,
    25222522        '[ws_images_setInfo]'
     
    25242524        .', possible values are {replace, append}.'
    25252525        );
    2526       exit();
    25272526    }
    25282527  }
     
    26112610  if (count($cat_ids) == 0)
    26122611  {
    2613     new PwgError(
     2612    return new PwgError(
    26142613      500,
    26152614      '[ws_add_image_category_relations] there is no category defined in "'.$categories_string.'"'
    26162615      );
    2617     exit();
    26182616  }
    26192617
     
    26292627  if (count($unknown_cat_ids) != 0)
    26302628  {
    2631     new PwgError(
     2629    return new PwgError(
    26322630      500,
    26332631      '[ws_add_image_category_relations] the following categories are unknown: '.implode(', ', $unknown_cat_ids)
    26342632      );
    2635     exit();
    26362633  }
    26372634
Note: See TracChangeset for help on using the changeset viewer.