ZenphotoCMS Forum
Max Height in addition to Max Width - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Max Height in addition to Max Width (/thread-241.html)



Max Height in addition to Max Width - Ballwalker - 2006-01-21

Sometimes in a theme, it becomes necessary to have both a max width [b]and[/b] 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 ;-)




Max Height in addition to Max Width - trisweb - 2006-01-21

We should be able to integrate that functionality into the base release. Looks pretty useful. Thanks for the idea!




Max Height in addition to Max Width - kevito - 2006-06-23

This doesn't work in Zenphoto 1.0.3. Could anyone help me get this same result with the new code? Thanks!