Ignore:
Timestamp:
Aug 20, 2008, 2:35:22 AM (16 years ago)
Author:
rvelices
Message:
  • local.lang is loaded without fallback on default language or PHPWG_DEFAULT_LANGUAGE (needed to change the signature of load_language which became a little too big)
  • move a function from functions.inc.php to functions_picture.inc.php (included only when necessary)
  • removed some css (not as much as I wanted)
File:
1 edited

Legend:

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

    r2299 r2479  
    328328}
    329329
     330// The get_picture_size function return an array containing :
     331//      - $picture_size[0] : final width
     332//      - $picture_size[1] : final height
     333// The final dimensions are calculated thanks to the original dimensions and
     334// the maximum dimensions given in parameters.  get_picture_size respects
     335// the width/height ratio
     336function get_picture_size( $original_width, $original_height,
     337                           $max_width, $max_height )
     338{
     339  $width = $original_width;
     340  $height = $original_height;
     341  $is_original_size = true;
     342
     343  if ( $max_width != "" )
     344  {
     345    if ( $original_width > $max_width )
     346    {
     347      $width = $max_width;
     348      $height = floor( ( $width * $original_height ) / $original_width );
     349    }
     350  }
     351  if ( $max_height != "" )
     352  {
     353    if ( $original_height > $max_height )
     354    {
     355      $height = $max_height;
     356      $width = floor( ( $height * $original_width ) / $original_height );
     357      $is_original_size = false;
     358    }
     359  }
     360  if ( is_numeric( $max_width ) and is_numeric( $max_height )
     361       and $max_width != 0 and $max_height != 0 )
     362  {
     363    $ratioWidth = $original_width / $max_width;
     364    $ratioHeight = $original_height / $max_height;
     365    if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) )
     366    {
     367      if ( $ratioWidth < $ratioHeight )
     368      {
     369        $width = floor( $original_width / $ratioHeight );
     370        $height = $max_height;
     371      }
     372      else
     373      {
     374        $width = $max_width;
     375        $height = floor( $original_height / $ratioWidth );
     376      }
     377      $is_original_size = false;
     378    }
     379  }
     380  $picture_size = array();
     381  $picture_size[0] = $width;
     382  $picture_size[1] = $height;
     383  return $picture_size;
     384}
     385
    330386?>
Note: See TracChangeset for help on using the changeset viewer.