Changeset 14830


Ignore:
Timestamp:
May 7, 2012, 3:51:04 PM (9 years ago)
Author:
plg
Message:

multisize (derivatives): remove obsolete functions get_high_path,
get_high_url, get_high_location, get_picture_size

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_picture.inc.php

    r12920 r14830  
    2121// | USA.                                                                  |
    2222// +-----------------------------------------------------------------------+
    23 
    24 
    25 /*
    26  * @param element_info array containing element information from db;
    27  * at least 'id', 'path', 'has_high' should be present
    28  */
    29 function get_high_path($element_info)
    30 {
    31   $path = get_high_location($element_info);
    32   if (!empty($path) and !url_is_remote($path) )
    33   {
    34     $path = PHPWG_ROOT_PATH.$path;
    35   }
    36   return $path;
    37 }
    38 
    39 /**
    40  * @param element_info array containing element information from db;
    41  * at least 'id', 'path', 'has_high' should be present
    42  */
    43 function get_high_url($element_info)
    44 {
    45   $url = get_high_location($element_info);
    46   if (!empty($url) and !url_is_remote($url) )
    47   {
    48     $url = embellish_url(get_root_url().$url);
    49   }
    50   // plugins want another url ?
    51   return trigger_event('get_high_url', $url, $element_info);
    52 }
    53 
    54 /**
    55  * @param element_info array containing element information from db;
    56  * at least 'id', 'path', 'has_high' should be present
    57  */
    58 function get_high_location($element_info)
    59 {
    60   $location = '';
    61   if ($element_info['has_high'] == 'true')
    62   {
    63     $pi = pathinfo($element_info['path']);
    64     $location=$pi['dirname'].'/pwg_high/'.$pi['basename'];
    65   }
    66   return trigger_event( 'get_high_location', $location, $element_info);
    67 }
    68 
    6923
    7024
     
    174128  return $result;
    175129}
    176 
    177 // The get_picture_size function return an array containing :
    178 //      - $picture_size[0] : final width
    179 //      - $picture_size[1] : final height
    180 // The final dimensions are calculated thanks to the original dimensions and
    181 // the maximum dimensions given in parameters.  get_picture_size respects
    182 // the width/height ratio
    183 function get_picture_size( $original_width, $original_height,
    184                            $max_width, $max_height )
    185 {
    186   $width = $original_width;
    187   $height = $original_height;
    188   $is_original_size = true;
    189 
    190   if ( $max_width != "" )
    191   {
    192     if ( $original_width > $max_width )
    193     {
    194       $width = $max_width;
    195       $height = floor( ( $width * $original_height ) / $original_width );
    196     }
    197   }
    198   if ( $max_height != "" )
    199   {
    200     if ( $original_height > $max_height )
    201     {
    202       $height = $max_height;
    203       $width = floor( ( $height * $original_width ) / $original_height );
    204       $is_original_size = false;
    205     }
    206   }
    207   if ( is_numeric( $max_width ) and is_numeric( $max_height )
    208        and $max_width != 0 and $max_height != 0 )
    209   {
    210     $ratioWidth = $original_width / $max_width;
    211     $ratioHeight = $original_height / $max_height;
    212     if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) )
    213     {
    214       if ( $ratioWidth < $ratioHeight )
    215       {
    216         $width = floor( $original_width / $ratioHeight );
    217         $height = $max_height;
    218       }
    219       else
    220       {
    221         $width = $max_width;
    222         $height = floor( $original_height / $ratioWidth );
    223       }
    224       $is_original_size = false;
    225     }
    226   }
    227   $picture_size = array();
    228   $picture_size[0] = $width;
    229   $picture_size[1] = $height;
    230   return $picture_size;
    231 }
    232 
    233130?>
Note: See TracChangeset for help on using the changeset viewer.