aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming/lib/ImageManager.php
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-07-11 15:36:36 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-07-12 13:00:07 +0200
commitd5dc6b2476662f46c2fd0ccf70b0dae976c5e0eb (patch)
treeb1fcd85660a5e7e950952a6bbbe80f41a8ed541d /apps/theming/lib/ImageManager.php
parent76943efa18bcd94d794b42cc1db8dfe57fa7a311 (diff)
downloadnextcloud-server-d5dc6b2476662f46c2fd0ccf70b0dae976c5e0eb.tar.gz
nextcloud-server-d5dc6b2476662f46c2fd0ccf70b0dae976c5e0eb.zip
feat(theming): Allow shipped backgrounds to have a dark variant
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/theming/lib/ImageManager.php')
-rw-r--r--apps/theming/lib/ImageManager.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php
index c44d6de128b..761b0c9a8ba 100644
--- a/apps/theming/lib/ImageManager.php
+++ b/apps/theming/lib/ImageManager.php
@@ -42,6 +42,9 @@ class ImageManager {
$cacheBusterCounter = $this->config->getAppValue(Application::APP_ID, 'cachebuster', '0');
if ($this->hasImage($key)) {
return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => $key ]) . '?v=' . $cacheBusterCounter;
+ } elseif ($key === 'backgroundDark' && $this->hasImage('background')) {
+ // Fall back to light variant
+ return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'background' ]) . '?v=' . $cacheBusterCounter;
}
switch ($key) {
@@ -49,11 +52,16 @@ class ImageManager {
case 'logoheader':
case 'favicon':
return $this->urlGenerator->imagePath('core', 'logo/logo.png') . '?v=' . $cacheBusterCounter;
+ case 'backgroundDark':
case 'background':
// Removing the background defines its mime as 'backgroundColor'
$mimeSetting = $this->config->getAppValue('theming', 'backgroundMime', '');
if ($mimeSetting !== 'backgroundColor') {
- return $this->urlGenerator->linkTo(Application::APP_ID, 'img/background/' . BackgroundService::DEFAULT_BACKGROUND_IMAGE);
+ $image = BackgroundService::DEFAULT_BACKGROUND_IMAGE;
+ if ($key === 'backgroundDark') {
+ $image = BackgroundService::SHIPPED_BACKGROUNDS[$image]['dark_variant'] ?? $image;
+ }
+ return $this->urlGenerator->linkTo(Application::APP_ID, "img/background/$image");
}
}
return '';