diff options
author | Michael Weimann <mail@michael-weimann.eu> | 2018-08-28 12:01:32 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-10-02 08:37:54 +0200 |
commit | 92049c3ceb4121c6e424e8ba902cc6ebc663c690 (patch) | |
tree | eb8a283e260e2b0918d13087c29af96d494fde58 /apps/theming/lib | |
parent | 7526971c95250807ac1ec485297919a27ee0dcfc (diff) | |
download | nextcloud-server-92049c3ceb4121c6e424e8ba902cc6ebc663c690.tar.gz nextcloud-server-92049c3ceb4121c6e424e8ba902cc6ebc663c690.zip |
Switches the default logo color depending on the primary color
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Diffstat (limited to 'apps/theming/lib')
-rw-r--r-- | apps/theming/lib/ImageManager.php | 2 | ||||
-rw-r--r-- | apps/theming/lib/ThemingDefaults.php | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php index dfbdb582da6..6a42c22aba5 100644 --- a/apps/theming/lib/ImageManager.php +++ b/apps/theming/lib/ImageManager.php @@ -84,6 +84,8 @@ class ImageManager { case 'logoheader': case 'favicon': return $this->urlGenerator->imagePath('core', 'logo.png') . '?v=' . $cacheBusterCounter; + case 'logo-blue': + return $this->urlGenerator->imagePath('core', 'logo-blue.png') . '?v=' . $cacheBusterCounter; case 'background': return $this->urlGenerator->imagePath('core', 'background.png') . '?v=' . $cacheBusterCounter; } diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 1df7a9f17bb..5a14e8a7903 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -275,7 +275,7 @@ class ThemingDefaults extends \OC_Defaults { 'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'" ]; - $variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')"; + $variables['image-logo'] = "url('". $this->getLogoUrl() ."')"; $variables['image-logoheader'] = "'".$this->imageManager->getImageUrl('logoheader')."'"; $variables['image-favicon'] = "'".$this->imageManager->getImageUrl('favicon')."'"; $variables['image-login-background'] = "url('".$this->imageManager->getImageUrl('background')."')"; @@ -301,6 +301,24 @@ class ThemingDefaults extends \OC_Defaults { } /** + * Returns the logo url. + * If there is a custom logo, it just returns it. + * For the default logo it returns the white or blue one depending on the color luminance. + * + * @return string + */ + private function getLogoUrl() { + $logoMime = $this->config->getAppValue('theming', 'logoMime'); + $primaryColor = $this->getColorPrimary(); + $luminance = $this->util->calculateLuminance($primaryColor); + if ($logoMime === '' & $luminance > 0.8) { + return $this->imageManager->getImageUrl('logo-blue'); + } else { + return $this->imageManager->getImageUrl('logo'); + } + } + + /** * Check if the image should be replaced by the theming app * and return the new image location then * |