From a71134fa2df0ef482f9258bb4dea546b9492ba0c Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Fri, 12 Apr 2019 09:51:26 +0200 Subject: [PATCH] Visual Console Refator: now the background image scales to the VC size Former-commit-id: aba14a6b903e12239e7b619b22676c6d4b2a5a53 --- .../models/VisualConsole/Container.php | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/pandora_console/include/rest-api/models/VisualConsole/Container.php b/pandora_console/include/rest-api/models/VisualConsole/Container.php index 56136cc2ad..b3c7f33417 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Container.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Container.php @@ -146,21 +146,10 @@ final class Container extends Model */ private function extractBackgroundUrl(array $data) { - $backgroundUrl = static::notEmptyStringOr( + return static::notEmptyStringOr( static::issetInArray($data, ['backgroundURL']), null ); - - if ($backgroundUrl !== null) { - return $backgroundUrl; - } - - $backgroundImage = static::extractBackgroundImage($data); - if ($backgroundImage === null) { - return null; - } - - return 'images/console/background/'.$backgroundImage; } @@ -221,6 +210,32 @@ final class Container extends Model throw new \Exception('error fetching the data from the DB'); } + $backgroundUrl = static::extractBackgroundUrl($row); + $backgroundImage = static::extractBackgroundImage($row); + + if ($backgroundUrl === null && $backgroundImage !== null) { + $backgroundUrl = ui_get_full_url( + 'images/console/background/'.$backgroundImage + ); + + $width = (int) $row['width']; + $height = (int) $row['height']; + + if ($width > 0 && $height > 0) { + $q = [ + 'getFile' => 1, + 'thumb' => 1, + 'thumb_size' => $width.'x'.$height, + 'file' => $backgroundUrl, + ]; + $row['backgroundURL'] = ui_get_full_url( + 'include/Image/image_functions.php?'.http_build_query($q) + ); + } else { + $row['backgroundURL'] = $backgroundUrl; + } + } + return $row; }