summaryrefslogtreecommitdiff
path: root/core/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-23 01:27:50 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-23 01:27:50 +0000
commitf476e2169ee84922dfe48d5a5065e1eabe40713f (patch)
treecd6f5446320366cb634c72b9c95c1cdb1d6461d0 /core/helpers
parent0c89fdcfc88a88459c47fdf9df94f764d4ab7702 (diff)
Change photo::img_dimensions to take the dimensions, not a photo. This lets us use it in the watermark module too
Diffstat (limited to 'core/helpers')
-rw-r--r--core/helpers/photo.php21
1 files changed, 11 insertions, 10 deletions
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);
}
}