diff --git a/web/zm_html_view_montage.php b/web/zm_html_view_montage.php index a4a396dcb..7f9a61c53 100644 --- a/web/zm_html_view_montage.php +++ b/web/zm_html_view_montage.php @@ -47,8 +47,12 @@ while( $row = mysql_fetch_assoc( $result ) ) } $monitors[] = $row; } -$rows = intval(ceil(count($monitors)/ZM_WEB_MONTAGE_MAX_COLS)); -$cols = count($monitors)>=ZM_WEB_MONTAGE_MAX_COLS?ZM_WEB_MONTAGE_MAX_COLS:count($monitors); + +$max_cols = 8; +$cols = (int)((count($monitors)+1)/((int)((count($monitors)-1)/ZM_WEB_MONTAGE_MAX_COLS)+1)); +$rows = intval(ceil(count($monitors)/$cols)); +$last_cols = count($monitors)%$rows; + $widths = array(); $heights = array(); for ( $i = 0; $i < count($monitors); $i++ ) @@ -56,15 +60,13 @@ for ( $i = 0; $i < count($monitors); $i++ ) $monitor = $monitors[$i]; $frame_height = (ZM_WEB_MONTAGE_HEIGHT?ZM_WEB_MONTAGE_HEIGHT:$monitor['Height'])+(ZM_WEB_COMPACT_MONTAGE?0:16); $frame_width = (ZM_WEB_MONTAGE_WIDTH?ZM_WEB_MONTAGE_WIDTH:$monitor['Width']); - $row = $i/ZM_WEB_MONTAGE_MAX_COLS; - $col = $i%ZM_WEB_MONTAGE_MAX_COLS; + $row = $i/$cols; + $col = $i%$cols; if ( empty( $heights[$row] ) || $frame_height > $heights[$row] ) $heights[$row] = $frame_height; - if ( empty( $widths[$col] ) || $frame_width > $widths[$col] ) - $widths[$col] = $frame_width; + $widths[$row][] = $frame_width; } $row_spec = join( ',', $heights ); -$col_spec = join( ',', $widths ); ?> @@ -85,21 +87,28 @@ if ( ZM_WEB_COMPACT_MONTAGE ) - + + + + +