From 1ab294e2917df0811257aed3323591fc943c826e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 27 Mar 2020 12:43:21 -0400 Subject: [PATCH] Fix selecting layout after save by using value in session. When applying layout, if height is auto, set the img height to auto. --- web/skins/classic/views/js/montage.js | 9 ++++++--- web/skins/classic/views/montage.php | 12 ++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/web/skins/classic/views/js/montage.js b/web/skins/classic/views/js/montage.js index 00130f108..68a2acf2c 100644 --- a/web/skins/classic/views/js/montage.js +++ b/web/skins/classic/views/js/montage.js @@ -210,7 +210,6 @@ function Monitor(monitorData) { * @param {*} element - the event data passed by onchange callback */ function selectLayout(element) { - console.log(element); layout = $j(element).val(); if ( layout_id = parseInt(layout) ) { @@ -221,8 +220,8 @@ function selectLayout(element) { // Need to clear the current positioning, and apply the new monitor_frame = $j('#monitorFrame'+monitor.id); - if ( ! monitor_frame ) { - console.log("Error finding frame for " + monitor.id); + if ( !monitor_frame ) { + console.log('Error finding frame for ' + monitor.id); continue; } @@ -262,6 +261,10 @@ function selectLayout(element) { if ( streamImg.nodeName == 'IMG' ) { var src = streamImg.src; src = src.replace(/width=[\.\d]+/i, 'width=0' ); + if ( $j('#height').val() == 'auto' ) { + src = src.replace(/height=[\.\d]+/i, 'height=0' ); + streamImg.style.height = 'auto'; + } if ( src != streamImg.src ) { streamImg.src = ''; streamImg.src = src; diff --git a/web/skins/classic/views/montage.php b/web/skins/classic/views/montage.php index 45ebcb0cc..0009b9929 100644 --- a/web/skins/classic/views/montage.php +++ b/web/skins/classic/views/montage.php @@ -69,17 +69,19 @@ foreach ( $layouts as $l ) { } } foreach ( $layouts as $l ) { - if ( $l->Name() != "Freeform" ) + if ( $l->Name() != 'Freeform' ) $layoutsById[$l->Id()] = $l; } -session_start(); +zm_session_start(); $layout_id = ''; if ( isset($_COOKIE['zmMontageLayout']) ) { $layout_id = $_SESSION['zmMontageLayout'] = $_COOKIE['zmMontageLayout']; -#} elseif ( isset($_SESSION['zmMontageLayout']) ) { - #$layout_id = $_SESSION['zmMontageLayout']; + ZM\Logger::Debug("Using layout $layout_id"); +} elseif ( isset($_SESSION['zmMontageLayout']) ) { + $layout_id = $_SESSION['zmMontageLayout']; + ZM\Logger::Debug("Using layout $layout_id from session"); } $options = array(); @@ -88,6 +90,8 @@ $Positions = ''; if ( $layout_id and is_numeric($layout_id) and isset($layoutsById[$layout_id]) ) { $Layout = $layoutsById[$layout_id]; $Positions = json_decode($Layout->Positions(), true); +} else { + ZM\Logger::Debug("Layout not found"); } if ( $Layout and ( $Layout->Name() != 'Freeform' ) ) { // Use layout instead of other options