- Timestamp:
- May 7, 2012, 3:51:04 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_picture.inc.php
r12920 r14830 21 21 // | USA. | 22 22 // +-----------------------------------------------------------------------+ 23 24 25 /*26 * @param element_info array containing element information from db;27 * at least 'id', 'path', 'has_high' should be present28 */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 present42 */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 present57 */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 69 23 70 24 … … 174 128 return $result; 175 129 } 176 177 // The get_picture_size function return an array containing :178 // - $picture_size[0] : final width179 // - $picture_size[1] : final height180 // The final dimensions are calculated thanks to the original dimensions and181 // the maximum dimensions given in parameters. get_picture_size respects182 // the width/height ratio183 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 else220 {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 233 130 ?>
Note: See TracChangeset
for help on using the changeset viewer.