From f476e2169ee84922dfe48d5a5065e1eabe40713f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Dec 2008 01:27:50 +0000 Subject: Change photo::img_dimensions to take the dimensions, not a photo. This lets us use it in the watermark module too --- core/helpers/photo.php | 21 +++++++++++---------- core/views/admin_block_photo_stream.html.php | 3 ++- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'core') diff --git a/core/helpers/photo.php b/core/helpers/photo.php index bb470e58..10f3d1a0 100644 --- a/core/helpers/photo.php +++ b/core/helpers/photo.php @@ -107,18 +107,19 @@ class photo_Core { /** * Return scaled width and height. * - * @param Item_Model the photo - * @param integer the scaling factor - * @param string the output format using %d placeholders for width and height + * @param integer $width + * @param integer $height + * @param integer $max the target size for the largest dimension + * @param string $format the output format using %d placeholders for width and height */ - static function img_dimensions($photo, $max, $format="width=\"%d\" height=\"%d\"") { - if ($photo->width > $photo->height) { - $width = $max; - $height = (int)$max * ($photo->height / $photo->width); + static function img_dimensions($width, $height, $max, $format="width=\"%d\" height=\"%d\"") { + if ($width > $height) { + $new_width = $max; + $new_height = (int)$max * ($height / $width); } else { - $height = $max; - $width = (int)$max * ($photo->width / $photo->height); + $new_height = $max; + $new_width = (int)$max * ($width / $height); } - return sprintf($format, $width, $height); + return sprintf($format, $new_width, $new_height); } } diff --git a/core/views/admin_block_photo_stream.html.php b/core/views/admin_block_photo_stream.html.php index af8d8545..6f961b29 100644 --- a/core/views/admin_block_photo_stream.html.php +++ b/core/views/admin_block_photo_stream.html.php @@ -4,6 +4,7 @@

id") ?>"> - src="thumb_url() ?>" alt="" /> + width, $photo->height, 72) ?> + src="thumb_url() ?>" alt="" /> -- cgit v1.2.3