diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2010-06-17 08:03:08 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2010-06-17 08:03:08 -0700 |
commit | 38d09c5d1adae211d61b16d82448b616318b951e (patch) | |
tree | 390359b70d6e7861436beddf6af7424c26c22147 /modules/gallery/models | |
parent | 3d4f04e827f54c3e4dec6a7d1e8e3bf78cf9603a (diff) |
Scale a movie to the resize size so that it doesn't overflow into the sidebar.
Diffstat (limited to 'modules/gallery/models')
-rw-r--r-- | modules/gallery/models/item.php | 15 |
1 files changed, 14 insertions, 1 deletions
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}"; } |