Max Height in addition to Max Width

Sometimes in a theme, it becomes necessary to have both a max width and max height with different variables. Zenphoto doesn't currently allow that, But I modified the script to do just that. (Please excuse the hack-ish nature of this, I'm not a very good php guy):

In config.php, change lines 60 - 63 from:
`

$conf['image_size'] = 595;

// If this is set to true, then the longest side of the image will be $image_size.

// Otherwise, the *width* of the image will be $image_size.

$conf['image_use_longest_side'] = true;

`

to:

`

$conf['width_image_size'] = 595;

// set this to the maximum height you want an image to be

//

$conf['height_image_size'] = 500;

`

and in i.php, change line 13 from:

`

$image_use_longest_side = zp_conf('image_use_longest_side');

`

to:

`

$height_image_size = zp_conf('height_image_size');

`

and lines 68 -75 from:

`

} else {

if ($image_use_longest_side && $h > $w) {

$newh = $size;

$neww = round(($w / $h) * $size);

} else {

$neww = $size;

$newh = round(($h / $w) * $size);

}

`

to:

`

} else {

$tempw = $size;

$temph = round(($h / $w) * $size);

if ($temph > $height_image_size) {

$newh = $height_image_size;

$neww = round(($tempw / $temph) * $height_image_size);

} else {

$newh=$temph;

$neww=$tempw;

}

`

it works, but I'm sure someone can make the code look a little more pretty ;-)

Comments

  • trisweb Administrator
    We should be able to integrate that functionality into the base release. Looks pretty useful. Thanks for the idea!
  • kevito Member
    This doesn't work in Zenphoto 1.0.3. Could anyone help me get this same result with the new code? Thanks!
Sign In or Register to comment.