Visual Console Refator: now the background image scales to the VC size

Former-commit-id: aba14a6b903e12239e7b619b22676c6d4b2a5a53
This commit is contained in:
Alejandro Gallardo Escobar 2019-04-12 09:51:26 +02:00
parent 179702979a
commit a71134fa2d
1 changed files with 27 additions and 12 deletions

View File

@ -146,21 +146,10 @@ final class Container extends Model
*/ */
private function extractBackgroundUrl(array $data) private function extractBackgroundUrl(array $data)
{ {
$backgroundUrl = static::notEmptyStringOr( return static::notEmptyStringOr(
static::issetInArray($data, ['backgroundURL']), static::issetInArray($data, ['backgroundURL']),
null 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'); 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; return $row;
} }