From 38d09c5d1adae211d61b16d82448b616318b951e Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 17 Jun 2010 08:03:08 -0700 Subject: Scale a movie to the resize size so that it doesn't overflow into the sidebar. --- modules/gallery/models/item.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index e42430bf..5e8a2d09 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -671,8 +671,21 @@ class Item_Model extends ORM_MPTT { */ public function movie_img($extra_attrs) { $v = new View("movieplayer.html"); + $max_size = module::get_var("gallery", "resize_size", 640); + $width = $this->width; + $height = $this->height; + if ($width > $max_size || $height > $max_size) { + if ($width > $height) { + $height *= $max_size / $width; + $width = $max_size; + } else { + $width *= $max_size / $height; + $height = $max_size; + } + } + $v->attrs = array_merge($extra_attrs, - array("style" => "display:block;width:{$this->width}px;height:{$this->height}px")); + array("style" => "display:block;width:{$width}px;height:{$height}px")); if (empty($v->attrs["id"])) { $v->attrs["id"] = "g-item-id-{$this->id}"; } -- cgit v1.2.3