Skip to content

Commit

Permalink
Scale a movie to the resize size so that it doesn't overflow into the…
Browse files Browse the repository at this point in the history
… sidebar.
  • Loading branch information
Tim Almdal committed Jun 17, 2010
1 parent 3d4f04e commit 38d09c5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion modules/gallery/models/item.php
Expand Up @@ -671,8 +671,21 @@ public function resize_img($extra_attrs) {
*/
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}";
}
Expand Down

0 comments on commit 38d09c5

Please sign in to comment.