From 8f87a030c8abe447feac22022fa6223248979601 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 20 Dec 2008 23:19:12 +0000 Subject: Implement the photo stream with the most recently uploaded photos. --- core/helpers/photo.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'core/helpers/photo.php') diff --git a/core/helpers/photo.php b/core/helpers/photo.php index 00aff447..bb470e58 100644 --- a/core/helpers/photo.php +++ b/core/helpers/photo.php @@ -104,4 +104,21 @@ class photo_Core { return $form; } + /** + * 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 + */ + 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); + } else { + $height = $max; + $width = (int)$max * ($photo->width / $photo->height); + } + return sprintf($format, $width, $height); + } } -- cgit v1.2.3