Problem/Motivation

Tokens for retrieving site logos such as `[site:logo]`, `[site:logo:default-theme]`, and `[site:logo:active-theme]` are currently missing from Drupal core. This functionality partially existed in Drupal 7, but was removed in the transition to Drupal 8+, resulting in a regression.

This impacts use cases where site builders or module developers want to programmatically access different theme-specific or site-wide logos, such as when rendering tokens in blocks or email templates.

Steps to reproduce

1. Install a fresh Drupal 10 or 11 site.
2. Enable the Token module.
3. Attempt to use `[site:logo]` or `[site:logo:active-theme]` in a token context (e.g., block, email).
4. Observe that the tokens are unavailable or do not resolve.

Proposed resolution

Introduce a set of new site logo-related tokens to core:

  • `[site:logo]`: Resolves to the logo of the active theme.
  • `[site:logo:default-theme]`: Resolves to the logo configured for the site's default theme.
  • `[site:logo:active-theme]`: Explicitly resolves to the active theme’s logo.
  • `[site:logo:theme-machine_name]` and `[site:logo:theme-machine_name:url]`: Dynamic tokens for each installed theme.

These tokens are implemented using the existing `site` token type. Technically, new token "types" such as `site-logo` and `site-logo-properties` are introduced, but these serve primarily to provide deeper token nesting and are resolved internally via `$token_service->findWithPrefix`.

Concerns from earlier in the issue (e.g., mail rendering and token type structure) have been addressed:

  • Using tokens in emails: Users can explicitly choose the correct logo token (e.g., `[site:logo:default-theme]`) depending on context.
  • (#173–#180): Clarified that no truly new top-level token type is introduced, only structured subtypes under `site`.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#250 2842780-nr-bot_03l7btty.txt548 bytesneeds-review-queue-bot
#246 2842780-nr-bot_eg1g29eb.txt776 bytesneeds-review-queue-bot
#244 2842780-nr-bot_kr3uwc4d.txt776 bytesneeds-review-queue-bot
#242 2842780-242.patch19.24 KBgrevil
#225 2842780-224.patch18.85 KBanybody
#216 2842780-nr-bot.txt1.66 KBneeds-review-queue-bot
#200 2842780-nr-bot.txt4.02 KBneeds-review-queue-bot
#195 2842780-195.patch15.95 KB_utsavsharma
#195 interdiff_194-195.txt15.76 KB_utsavsharma
#194 2023-10-10-2842780-194.patch16.23 KBgouthamraon
#193 2842780-193.patch4.68 KBatul4drupal
#190 2842780-add-site-logo-token-MR-4236-190.diff15.79 KBanybody
#179 After_Patch.PNG31.56 KBgaurav-mathur
#179 Before_Patch.PNG66.74 KBgaurav-mathur
#168 interdiff_166-168.txt1.18 KBneograph734
#168 2842780-168.patch16.1 KBneograph734
#166 2842780-166.patch16.04 KBneograph734
#165 interdiff_159-165.txt6.12 KBneograph734
#165 2842780-165.patch16 KBneograph734
#164 interdiff_159-164.txt776 bytespradhumanjain2311
#164 2842780-164.patch15.47 KBpradhumanjain2311
#159 interdiff_145-159.txt9.33 KBneograph734
#159 2842780-159.patch15.66 KBneograph734
#157 2842780-157.patch13.29 KBneograph734
#155 2842780-155.patch27.11 KBneograph734
#152 2842780-152.patch15.61 KBneograph734
#145 interdiff-143-145.txt3.65 KBneograph734
#145 2842780-145.patch15.61 KBneograph734
#143 interdiff-135-143.txt4.46 KBneograph734
#143 2842780-143.patch15.67 KBneograph734
#140 Screenshot_1.jpg139.35 KBAnnaE1990
#135 interdiff-133-135.txt2.07 KBpaulocs
#135 2842780-135.patch14.92 KBpaulocs
#134 2842780-after_patch-133_2.png32.29 KBabhijith s
#134 2842780-after_patch-133_1.png112.57 KBabhijith s
#134 2842780-before_patch.png54.63 KBabhijith s
#133 interdiff_131_133.txt3.81 KBneograph734
#133 2842780-133.patch15.14 KBneograph734
#131 interdiff_129-131.txt1.14 KBneograph734
#131 2842780-131.patch15.21 KBneograph734
#129 interdiff_120-129.txt19.56 KBneograph734
#129 2842780-129.patch15.2 KBneograph734
#122 token_for_site_logo-2842780-121-D8.patch1.09 KBIhorMaster
#120 interdiff-110-120.txt3.35 KBkishor_kolekar
#120 2842780-120.patch16.64 KBkishor_kolekar
#110 2842780-110.patch16.51 KBtr
#108 2842780-108.patch16.36 KByogeshmpawar
#102 token_for_site_logo-2842780-102.patch16.49 KBstomusic
#94 interdiff.txt43.91 KBneograph734
#94 token_for_site_logo-2842780-94.patch16.66 KBneograph734
#87 token_for_site_logo-2842780-87.patch16.72 KBneograph734
#84 token_for_site_logo-2842780-84.patch33.79 KBneograph734
#82 interdiff.txt24.44 KBneograph734
#82 token_for_site_logo-2842780-82.patch33.79 KBneograph734
#77 interdiff.txt31.8 KBneograph734
#77 token_for_site_logo-2842780-77.patch15.73 KBneograph734
#72 token_for_site_logo-2842780-72.diff14.55 KBneograph734
#71 logo_tokens.png35.1 KBneograph734
#66 interdiff-2842780-55-61.txt750 bytesvenkatesh rajan.j
#61 token_for_site_logo-2842780-61.patch11.61 KBvenkatesh rajan.j
#56 token_error.png61.8 KBvenkatesh rajan.j
#55 interdiff.txt8.42 KBneograph734
#55 2842780-55-token_for_site_logo.patch11.72 KBneograph734
#52 site-logo-token.png71.51 KBksujitha18
#52 omega-token.png48.13 KBksujitha18
#52 omega-content.png80.22 KBksujitha18
#52 logo-token.png76.2 KBksujitha18
#52 body-help-text.png47.6 KBksujitha18
#52 article-content.png81.04 KBksujitha18
#50 2842780-50-token_for_site_logo.patch12.18 KBneograph734
#50 interdiff.txt1.46 KBneograph734
#49 interdiff.txt4.35 KBneograph734
#49 2842780-49-token_for_site_logo.patch12.17 KBneograph734
#48 interdiff.txt4.06 KBneograph734
#48 2842780-48-token_for_site_logo.patch12.43 KBneograph734
#44 2842780-44-token_for_site_logo.patch11.67 KBneograph734
#44 interdiff.txt2.06 KBneograph734
#41 2842780-41-token_for_site_logo.patch11.67 KBneograph734
#39 2842780-38-token_for_site_logo.patch23.47 KBneograph734
#37 interdiff.txt26.29 KBneograph734
#37 2842780-37-token_for_site_logo.patch23.47 KBneograph734
#24 interdiff.txt1.67 KBMunavijayalakshmi
#24 2842780-24-token_for_site_logo.patch10.05 KBMunavijayalakshmi
#23 2842780-23-token_for_site_logo.patch10.21 KBneograph734
#21 2842780-21-token_for_site_logo.patch8.33 KBneograph734
#20 2842780-20-token_for_site_logo.patch4.17 KBPavan B S
#15 interdiff-2842780-12-14.txt598 byteswturrell
#15 2842780-14-token_for_site_logo.patch4.29 KBwturrell
#13 2842780-12-token_for_site_logo.patch4.5 KBneograph734
#9 2842780-9-token_for_site_logo.patch4.5 KBneograph734
#7 2842780-7-token_for_site_logo.patch4.47 KBneograph734
#2 2842780-2-token_for_site_logo.patch1.58 KBneograph734

Issue fork drupal-2842780

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Neograph734 created an issue. See original summary.

neograph734’s picture

Status: Active » Needs review
StatusFileSize
new1.58 KB
neograph734’s picture

Issue summary: View changes
neograph734’s picture

Issue summary: View changes
kopeboy’s picture

Thanks, let's hope we can get this on D7 as well (if soon)

neograph734’s picture

Kopeboy, if you have the time, you could speed this up by helping to test for Drupal 8 first.

neograph734’s picture

StatusFileSize
new4.47 KB

Also implemented tests for the tokens and assumed system.theme.global would be a suitable config for the addCacheableDependency().

Status: Needs review » Needs work

The last submitted patch, 7: 2842780-7-token_for_site_logo.patch, failed testing.

neograph734’s picture

StatusFileSize
new4.5 KB

Lets try it like this...

neograph734’s picture

Status: Needs work » Needs review
kopeboy’s picture

@Neograph734 Haven't made any website on Drupal 8 yet, sorry.
(Cause Omega8.cc aren't supporting it yet :/ have any good, specialized & cheap hosting for europe? :D )

neograph734’s picture

Uppercased url in token description to be URL, in order to be consistent with other tokens.

neograph734’s picture

StatusFileSize
new4.5 KB

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

wturrell’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: +String change in 8.3.0
StatusFileSize
new4.29 KB
new598 bytes

Review:

- the sole change in my patch is removing one piece of whitespace, so I'm marking this RTBC at the same time
- as @neograph734 says, the other site tokens are already in core, so see no objection for this to be
- patch applies cleanly on 8.3.x and works as described
- has automated tests, which I ran locally (I also ran a test-only patch and verified it failed)
- added issue summary template + steps to reproduce
- code style fine otherwise
- changes all in scope
- @neograph734 mentions doubts over the metadata in the IS, but has added the appropriate tests and it looks OK to me
- names of new tokens are sensible/consistent with what we already have
- this contains new translatable strings, tagged as string change
- no UI (CSS/JS) changes (other than the new text in token module - Available tokens window)

wturrell’s picture

Issue tags: +token
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/system.tokens.inc
@@ -127,6 +135,24 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
+          $logo_url = theme_get_setting('logo.url');
...
+          $logo_url = theme_get_setting('logo.url');

So if you're using Seven as your admin theme and you send an email from the admin interface it's going to use seven logo. Also what happens if the bartik logo is customised but not the global setting.

I think the only option is to have a logo per theme and the global one. But one thing that is interesting - theme_get_setting('logo.url') will return you the logo url of the active theme so I'm not sure that using theme_get_setting is right here.

What's for sure is that we need more testing of what happens when you have multiple themes with different logos.

neograph734’s picture

@wturrell thanks for the review.

@alexpott, feedback per point.

So if you're using Seven as your admin theme and you send an email from the admin interface it's going to use seven logo.

If there is a seven logo configured, probably, yes. Though most people probably do not specifically configure a seven logo, it is more likely the global logo will be used as fallback. But it is a possible scenario indeed.

Also what happens if the bartik logo is customized but not the global setting.

It was my understanding that theme_get_setting() would fetch the global permissions first and override them with theme specific settings if applicable. So if theme_get_setting() detects bartik as the active theme, it will show the altered bartik logo.

I think the only option is to have a logo per theme and the global one.

Sticking to the situation of mails, this makes not much sense to me; One would have to configure mail texts for every theme. This would greatly reduce the usability.

But one thing that is interesting - theme_get_setting('logo.url') will return you the logo url of the active theme so I'm not sure that using theme_get_setting is right here.

For user interactions this will work fine as the user will get everything in his selected theme. For admin triggered interactions this might become troublesome indeed.

What's for sure is that we need more testing of what happens when you have multiple themes with different logos.

After reading your scenarios I agree some more work can be done. In the end, all the issues you have pointed out originate from the same problem; How to know what theme to select. But that is difficult as well because this is a (non user specific) global token (to remain similar to site name and slogan).

If you have any idea on how to to detect the theme of the current user in, for instance a batch operation, and provide that to the replacement token I'd be happy to hear it. I'll give this some more thought as well.

neograph734’s picture

+++ b/core/modules/system/system.tokens.inc
@@ -127,6 +135,24 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
+        case 'logo':
+          $config = \Drupal::config('system.theme.global');
+          $bubbleable_metadata->addCacheableDependency($config);

Thinking of this again, I do not think the global theme is the correct cacheable dependency. We should use the theme cache context instead to be able to properly serve the logo per theme.

theme_get_setting() could work because it has a second parameter to pass a predefined theme: theme_get_setting($setting_name, $theme = NULL) {}. We'd only have to figure out what theme to use.

Alternatively, we could also choose to keep the global logo implementation as it is (for the simple cases when there is only one theme) and create something like a [user:theme-logo] token to be able to serve every user the logo of his selected theme. This could be explained in the [site:logo] token description.

Pavan B S’s picture

StatusFileSize
new4.17 KB

Rerolled the patch, please review.

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new8.33 KB

Ok, I have reworked the approach a bit.

[site:logo] now queries the default theme and passes that to theme_get_setting(). If all goes well, that means it should show the default theme logo, unless overridden by a global logo, unless overridden by a theme logo. This should be enough for most cases.
For those people who need more control, there is also [site:logo:<theme-name>], for instance [site:logo:bartik], providing the logo of the provided theme. (Again in the same order, default theme logo, global logo, manual theme logo).

The same applies to [site:logo-url] and [site:logo-url:<theme-name>].

I guess this method will provide the most predictable behavior.

Status: Needs review » Needs work

The last submitted patch, 21: 2842780-21-token_for_site_logo.patch, failed testing.

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new10.21 KB

This should do it.

Munavijayalakshmi’s picture

StatusFileSize
new10.05 KB
new1.67 KB
+++ b/core/modules/system/system.tokens.inc
@@ -149,6 +183,54 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
+          // If there is no logo key, we set the theme to NULL to use the global fallback.
...
+          // If there is no logo key, we set the theme to NULL to use the global fallback.

Line exceeding 80 characters

+++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
@@ -129,6 +129,106 @@ public function testSystemSiteTokenReplacement() {
+   * Tests the generation of site logo tokens
...
+    // Install Bartik

Comments should (noramlly) begin with a capital letter and end with a full stop / period .

Fixed and attached new patch.

neograph734’s picture

Issue summary: View changes

Updated the description to include the [site:logo:?] tokens.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

anybody’s picture

#24 works great. I'd suggest to RTBC this. Can we get some more feedback?

matthiasm11’s picture

Applied the patch from #24, still working on 8.4.2.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Yes I can confirm that too. #24 RTBC.

plach’s picture

Version: 8.4.x-dev » 8.5.x-dev

Thanks for your work here! I'm going to retest #24 against 8.5.x as feature requests should target the development branch. A release manager may consider backporting this to the production branch (8.4.x).

Mixologic’s picture

Image dimension test fails were artifacts of php container upgrade issues, unrelated to this patch.

larowlan’s picture

+++ b/core/modules/system/system.tokens.inc
@@ -127,6 +135,32 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
+          $replacements[$original] = \Drupal::service('renderer')->renderPlain($build);

@@ -149,6 +183,56 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
+          $replacements[$original] = \Drupal::service('renderer')->renderPlain($build);

Should this render in a context, catch any bubbleable metadata and add to the existing one?

plach’s picture

Good stuff! I found only a few minor things and a possible improvement:

  1. +++ b/core/modules/system/system.tokens.inc
    @@ -36,6 +36,14 @@ function system_token_info() {
    +  $site['logo'] = [
    +      'name' => t("Logo"),
    +      'description' => t("The default site logo, or the logo of a specified theme."),
    +  ];
    +  $site['logo:url'] = [
    +      'name' => t("Logo URL"),
    +      'description' => t("The URL of the default site logo, or the logo of a specified theme."),
    +  ];
    

    Wrong indentation :)

  2. +++ b/core/modules/system/system.tokens.inc
    @@ -149,6 +183,56 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +        $themes = \Drupal::service('theme_handler')->listInfo();
    ...
    +        $themes = \Drupal::service('theme_handler')->listInfo();
    

    These calls can be moved outside the foreach loop.

  3. +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
    @@ -129,6 +129,106 @@ public function testSystemSiteTokenReplacement() {
    +    // Generate and test tokens.
    +    $tests = [];
    +    $tests['[site:logo]'] = $global_logo;
    +    $tests['[site:logo:bartik]'] = $global_logo;
    +    $tests['[site:logo:not-enabled-theme]'] = '[site:logo:not-enabled-theme]';
    +    $tests['[site:logo-url]'] = $system_theme_global_config->get('logo.path');
    +    $tests['[site:logo-url:bartik]'] = $system_theme_global_config->get('logo.path');
    +
    ...
    +    $tests = [];
    +    $tests['[site:logo]'] = $theme_logo;
    +    $tests['[site:logo:bartik]'] = $theme_logo;
    +    $tests['[site:logo:not-enabled-theme]'] = '[site:logo:not-enabled-theme]';
    +    $tests['[site:logo-url]'] = $theme_config->get('logo.path');
    +    $tests['[site:logo-url:bartik]'] = $theme_config->get('logo.path');
    +    $tests['[site:logo-url:not-enabled-theme]'] = '[site:logo-url:not-enabled-theme]';
    

    Can we add the case of a non-default theme with a custom logo and check whether the token is correctly generated also in both of these cases?

  4. +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
    @@ -129,6 +129,106 @@ public function testSystemSiteTokenReplacement() {
    +      $this->assertEqual($output, $expected, new FormattableMarkup('System site information token %token replaced.', ['%token' => $input]));
    +      $this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
    ...
    +      $this->assertEqual($output, $expected, new FormattableMarkup('System site information token %token replaced.', ['%token' => $input]));
    +      $this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
    

    Deprecated calls, we should use ::assertEquals().

In all the four hunks of system.tokens.inc I'm seeing some duplicate code. I'm wondering whether we could factor it out to an internal helper function, something like this:

function _system_tokens_get_actual_theme($theme) {
  // Retrieve configurations.
  $config = \Drupal::config('system.theme.global');
  $bubbleable_metadata->addCacheableDependency($config);
  $theme_config = \Drupal::config($theme . '.settings');
  $bubbleable_metadata->addCacheableDependency($theme_config);

  // If there is no logo key, we set the theme to NULL to use the global
  // fallback.
  if (!$theme_config->get('logo.path')) {
    $theme = NULL;
  }

  return $theme;
}

In the first two cases we would be passing the default theme as parameter.

plach’s picture

Status: Reviewed & tested by the community » Needs work
plach’s picture

One more, sorry:

+++ b/core/modules/system/system.tokens.inc
@@ -36,6 +36,14 @@ function system_token_info() {
+  $site['logo'] = [
...
+  $site['logo:url'] = [

What about adding also info about all the theme-specific tokens?

neograph734’s picture

@plach (and others), thanks for taking a look. Could you help me out with a few questions?

Deprecated calls, we should use ::assertEquals().

All other assertions in that file still use the old assertEqual(), I felt it would not be right to combine old and new standards, so I went ahead with what was already present in the file. If you still feel I should update it, I will do it.

What about adding also info about all the theme-specific tokens?

I am not sure how to. Would it be something like this?

function system_token_info() {
  ...
  $site['logo'] = [
    'name' => t("Logo"),
    'description' => t("The default site logo."),
  ];
  $site['logo:?'] = [
    'name' => t("Logo for a specific theme"),
    'description' => t("The site logo of a specified theme (use the theme's system name)."),
  ];
  ...
}

I will implement the rest of your feedback shortly.

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new23.47 KB
new26.29 KB

Let's see how this holds up.

Status: Needs review » Needs work

The last submitted patch, 37: 2842780-37-token_for_site_logo.patch, failed testing. View results

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new23.47 KB

Rebased the code. Lets hop it works now.

Status: Needs review » Needs work

The last submitted patch, 39: 2842780-38-token_for_site_logo.patch, failed testing. View results

neograph734’s picture

StatusFileSize
new11.67 KB

Like this?

neograph734’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 41: 2842780-41-token_for_site_logo.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new2.06 KB
new11.67 KB

That was a stupid typo. The other fails do not seem to be related.

plach’s picture

Changes look good to me, thanks!

All other assertions in that file still use the old assertEqual(), I felt it would not be right to combine old and new standards, so I went ahead with what was already present in the file. If you still feel I should update it, I will do it.

I don't feel strongly about this, but it seems to me that our deprecation policy recommends not to introduce new usages of deprecated code, although it's not crystal clear on this matter:

Contributed project developers, as well as those maintaining custom integrations, should follow the deprecations when possible and use the latest APIs available.

I'm assuming that if it applies for contrib/custom code it should apply for core code as well.

I am not sure how to. Would it be something like this?

Well, I was thinking about explicitly listing the available theme-specific tokens.

To validate this suggestion, I enabled the Token module on a vanilla core installation and it seems to me that when values are known in advance the Tokens UI lists them explicitly. Question marks are used when the suffix in not specified or can be a custom string.

The last submitted patch, 41: 2842780-41-token_for_site_logo.patch, failed testing. View results

neograph734’s picture

Thanks, as you might have seen already, I had updated the assertions.

Well, I was thinking about explicitly listing the available theme-specific tokens.

Since there can theoretically be an endless list of enabled themes, I felt the question mark approach would be more appropriate, rather than listing all themes. On the other hand, the patch uses the system names of the themes, which might be

I am however struggling because none of the core tokens seem to explicitly list the question mark, yet they show up in the list of available tokens (for instance the custom date format). So explicitly defining them seems to be wrong. On the other hand, the date tokens seem to list all available date formats including all custom ones.
Once I have figured out how they do it, I will try to put all themes in the list.

neograph734’s picture

StatusFileSize
new12.43 KB
new4.06 KB

This should be listing the different tokens for all themes.

neograph734’s picture

StatusFileSize
new12.17 KB
new4.35 KB

Hmm, that was a bit jumping to conclusions. I had tested this at the top level and assumed that it would work at a sub level as well. But the items to not show up. Cluttering the site:* space does not seem to be nice either.

So another idea. List the abailable themes in the description.

neograph734’s picture

StatusFileSize
new1.46 KB
new12.18 KB

One small copy-paste error (site:token in the description of site:token-url) :(

The last submitted patch, 49: 2842780-49-token_for_site_logo.patch, failed testing. View results

ksujitha18’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new81.04 KB
new47.6 KB
new76.2 KB
new80.22 KB
new48.13 KB
new71.51 KB

@Neograph734

Good effort!. But this patch has one bugs. Please refer below metnioed steps for testing scenario

1. Applied patch (2842780-50-token_for_site_logo.patch)
2. Go to Structure -> Content type -> Article
3. Click Manage fields -> Edit Body field
4. Click "Browse available tokens" underneath help text.
#BUG 1
Token displayed "[site:logo:?]" and "[site:logo-url:?]". It does not refer the theme name by default. Manually I have added the theme name in the token like "[site:logo:bartik]" & " [site:logo-url:bartik]". Then Logo and logo reference url - /drupal-8/core/themes/seven/logo.svg displayed great

#BUG 2
Incase I have omega theme it does not work like "[site:logo:omega]" & " [site:logo-url:omega]". Refer attached screenshots

plach’s picture

Status: Reviewed & tested by the community » Needs work

I guess @ksujitha18 meant this :)

The RTBC status should be used when the patch is deemed ready for incorporation in the Drupal codebase.

neograph734’s picture

Thanks @ksujitha18,

Bug 1 is not a bug, but this is by design. It does not seem to be possible to define 3rd level tokens without chaining them. This means that it is impossible to define all tokens like [site:logo:<theme>]. The alternative [site:logo-<theme>] could work, but with multiple themes it would become harder to find other tokens like [site:name]. So it is [site:logo:?]. IMHO this is made very clear in the description:

The default site logo [site:logo], or for a provided theme [site:logo:?] (Available themes: bartikclassysevenstable).

(There should have been comma's there.)

I will give Omega a try. Have you tried clearing the cache?

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new11.72 KB
new8.42 KB

Tweaked the UI some more. List of available themes is comma separated, and the default token no longer has a question mark, but the description explains it can be chained with a theme name. The alternative option is to have them side by side and list [site:logo],
[site:logo:?], [site:logo-url] and [site:logo-url:?]. But for now that seems a bit too much. I think this will work.

I have changed the logic to obtain the logo, so it now also detects the default omega (and other theme's) logo, as well as overridden logos.

venkatesh rajan.j’s picture

StatusFileSize
new61.8 KB

@Neograph734,

#55, works only for the default site logo [site:logo] and site logo URL [site:logo-url].

Unable to use tokens like [site:logo:seven] or [site:logo-url:?]. Refer the screenshot

Please correct me if I am wrong.

neograph734’s picture

That is strange because the test passed... (And that requests the token for seven as well.) Did you clear the cache?

It might be because I have removed dynamic from system_token_info(). Could you try placing that back? (See the interdiff from #55).

venkatesh rajan.j’s picture

Awesome... When I add dynamic to the system_token_info() function, it's working perfectly.

Can you add in the patch as well?

neograph734’s picture

Status: Needs review » Needs work

I will put it back in once I have some time. Thanks for testing!

venkatesh rajan.j’s picture

Assigned: Unassigned » venkatesh rajan.j
venkatesh rajan.j’s picture

Status: Needs work » Needs review
StatusFileSize
new11.61 KB

Patch attached

venkatesh rajan.j’s picture

Assigned: venkatesh rajan.j » Unassigned

Status: Needs review » Needs work

The last submitted patch, 61: token_for_site_logo-2842780-61.patch, failed testing. View results

venkatesh rajan.j’s picture

Status: Needs work » Needs review
jeetendrakumar’s picture

Hi Venkatesh

Can you please attach interdiff file?

venkatesh rajan.j’s picture

StatusFileSize
new750 bytes

Hi jeetendrakumar,

Interdiff file attached.

Thanks for reviewing...

berdir’s picture

  1. +++ b/core/modules/system/system.tokens.inc
    @@ -127,6 +142,24 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +        case 'logo':
    +          $default_theme = \Drupal::config('system.theme')->get('default');
    +          $theme = _system_tokens_get_actual_theme($default_theme, $bubbleable_metadata);
    +          $logo_url = theme_get_setting('logo.url', $theme);
    

    I'm not sure if the default token should really use the default theme or if it should be using the *active* theme?

  2. +++ b/core/modules/system/system.tokens.inc
    @@ -192,3 +256,28 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +
    +/**
    + * @param $theme
    + *   The theme to load the logo for.
    

    missing function description.

neograph734’s picture

@Berdir, initially it was the active theme, but the feedback was that that would lead to unexpected behavior when using the tokens for mails sent via the admin interface. In such situations mails would be sent with the admin theme logo, instead of the 'normal' logo.

I'll have a look at the function description this weekend.

berdir’s picture

That is a valid point, but it will also use the *templates* of the active theme then, unless you use mailsystem and its setting for the mail theme.

If you send e-mails, you could explicitly specify the theme you want to have the token from. But if you e.g. use this token in metatags or so, then you'd want to have it respect the active theme?

One option would to always require an explicit selection and have site:logo:default and :active?

neograph734’s picture

But if you e.g. use this token in metatags or so, then you'd want to have it respect the active theme?

Valid point. I supposed most sites will use only one theme, so the default theme will suffice. But you are right that the active theme should be respected as well.

One option would to always require an explicit selection and have site:logo:default and :active?

Yes, I think that could work. It should not be that hard to add and the added value is significant. I will see if I can get it in.

neograph734’s picture

StatusFileSize
new35.1 KB

I have been playing around with hook_token_info a bit and I guess this will be my new approach.

Logo specific tokens

It provides a list of all themes as well as 'active' and 'default'. With below each item an :url suffixed token. UI wise I think this is the cleanest approach so far. However to achieve the different levels, the code became a bit more complicated:

/**
 * Implements hook_token_info().
 */
function system_token_info() {
  $types['site'] = [
    'name' => t("Site information"),
    'description' => t("Tokens for site-wide settings and other global information."),
  ];
  $types['site-logo'] = [
    'name' => t("Site logo's"),
    'description' => t("Tokens related to the site logo."),
    'needs-data' => 'site',
  ];
  $types['site-logo-theme'] = [
    'name' => t("Theme logo"),
    'description' => t("Tokens related to the theme specific logo's."),
    'needs-data' => 'site-logo',
  ];
  $types['date'] = [
    'name' => t("Dates"),
    'description' => t("Tokens related to times and dates."),
  ];

  // Chained tokens for site-wide settings and other global information.
  $site['logo'] = [
    'name' => t("Logo"),
    'description' => t("Tokens related to the site logo."),
    'type' => 'site-logo',
  ];

  // Logo related tokens.
  $logo['active'] = [
    'name' => t("Active theme logo"),
    'description' => t("The logo of the activated theme. (Pay attention when using this from the administrative interface, as the theme might be different.)"),
    'type' => 'site-logo-theme',
  ];
  $logo['default'] = [
    'name' => t("Default theme logo"),
    'description' => t("The logo that is configured for the standard theme."),
    'type' => 'site-logo-theme',
  ];
  // Obtain a list of installed themes.
  $themes = \Drupal::service('theme_handler')->listInfo();
  foreach ($themes as $theme => $val) {
    $logo[$theme] = [
      'name' => t("@theme logo", ['@theme' => $val->info['name']]),
      'description' => t("The logo for the %theme theme.", ['%theme' => $val->info['name']]),
      'type' => 'site-logo-theme',
    ];
  }

  // Theme specific logo tokens.
  $theme_logo['url'] = [
    'name' => t("URL"),
    'description' => t("The URL of the logo."),
  ];

  return [
    'types' => $types,
    'tokens' => [
      'site' => $site,
      'date' => $date,
      'site-logo' => $logo,
      'site-logo-theme' => $theme_logo,
    ],
  ];
}

I hope the added value outweighs the increased code complexity.

The next days I will work on implementing this and updating the tests. If for some reason you do not like this approach, please speak up now and safe me some work :)

neograph734’s picture

StatusFileSize
new14.55 KB

Oke, here it goes. No interdiff due to the large architectural change.

tr’s picture

One of the use cases frequently mentioned above is to use the new tokens to include a locally-stored image in an email. This is something that is not possible since #1494670: References to CSS, JS, and similar files should be root-relative URLs: avoids mixed content warnings & fewer bytes to send went in (almost two years ago), because now all URLs generated by core for local assets are relative URLs. And there is no way in core to force them to be absolute. Images can't/won't be shown in an email unless you can produce an absolute URL with the token.

So +1 for putting this in, but only if you can give us absolute URLs because email is one of the primary needs for these tokens.

There is a proposal in #2704597: Relative URLs in mails should be converted to absolute ones to fix this relative/absolute issue for email, but there has been little activity over there. I think the tokens should wait until that issue or something like it is resolved, otherwise you're going to see a LOT of bug reports/support requests/unhappy users of these new tokens when they don't work as expected.

plach’s picture

Didn't look at the code yet but I'm definitely +1 on the new approach. Thanks for putting it together!

I'm wondering whether default and active are reserved theme names or we could have some clashes in those cases...

neograph734’s picture

Well, https://www.drupal.org/project/active and https://www.drupal.org/project/default both show a 404 as of today, but it might be possible to register those names and install them in a site. We could do drupal-default and drupal-active, but then again there is nothing preventing people from registering those projects.

Adding a separation for core and contrib themes could be an option, but that would involve yet another layer of token types and a more complex UI.

plach’s picture

Would it be possible to implement something like the following?

[site:logo:active-theme]
[site:logo:default-theme]
[site:logo:theme:bartik] or [site:logo:theme-bartik]

neograph734’s picture

StatusFileSize
new15.73 KB
new31.8 KB

I started off with the [site:logo:theme:bartik] approach, but I could not get [site:logo:theme:bartik:url] to show up in the token browser. After some searching it appeared that the token browser comes with a recursion limit that would prevent these 'deep' tokens from showing (they did work though).

But to make sure all info would be visible for most of the users, I then went along the [site:logo:theme-bartik] route.

wim leers’s picture

plach’s picture

Status: Needs review » Needs work
Issue tags: -String change in 8.3.0 +String change in 8.5.0

Nice work! I manually tested this with emails and the Token module and it works fine.

I found only a few mostly minor issues in code:

  1. +++ b/core/modules/system/system.tokens.inc
    @@ -49,6 +59,40 @@ function system_token_info() {
    +    'description' => t("The logo of the activated theme. (Pay attention when using this from the administrative interface, as the theme might be different.)"),
    

    Shouldn't this say "active theme"? Also, the parentheses feel unnecessary to me.

  2. +++ b/core/modules/system/system.tokens.inc
    @@ -49,6 +59,40 @@ function system_token_info() {
    +    'description' => t("The logo that is configured for the standard theme."),
    

    Shouldn't this say "default theme"?

  3. +++ b/core/modules/system/system.tokens.inc
    @@ -49,6 +59,40 @@ function system_token_info() {
    +  $themes = \Drupal::service('theme_handler')->listInfo();
    

    We should filter out hidden themes (e.g. classy or stable), as those are usually base themes and are not available in the UI, so no logo can be configured.

  4. +++ b/core/modules/system/system.tokens.inc
    @@ -147,6 +196,63 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +  }
    +
    +  elseif ($type == 'site-logo') {
    ...
    +  }
    +
    +  elseif ($type == 'site-logo-properties' && !empty($data['theme'])) {
    

    Surplus empty lines.

  5. +++ b/core/modules/system/system.tokens.inc
    @@ -147,6 +196,63 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +      $name = (stripos($name, 'theme-') === 0) ? substr($name, 6) : $name;
    

    Does this mean we support also unprefixed names? These wouldn't be seen as valid tokens.

  6. +++ b/core/modules/system/system.tokens.inc
    @@ -192,3 +298,51 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    + *   If set to TRUE, the logo will be rendered. An url is returned otherwise.
    

    Missing (optional) prefix and default description.

  7. +++ b/core/modules/system/system.tokens.inc
    @@ -192,3 +298,51 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +  $logo_url = theme_get_setting('logo.url', $theme) ?: theme_get_setting('logo.url', $default_theme);
    

    Can we make this URL absolute, so that these tokens can be used in emails without waiting for #2704597: Relative URLs in mails should be converted to absolute ones?

  8. +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
    @@ -127,6 +127,161 @@ public function testSystemSiteTokenReplacement() {
    +    $tests['[site:logo:url]'] = '[site:logo:url]';
    

    Why aren't we supporting the global logo url?

  9. +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
    @@ -127,6 +127,161 @@ public function testSystemSiteTokenReplacement() {
    +      $output = $this->tokenService->replace($input, [], ['langcode' => $this->interfaceLanguage->getId()], $bubbleable_metadata);
    

    Do we need to specify the langcode here? If this is not necessary I'd leave it out, as it's confusing.

neograph734’s picture

Hi @plach, could you clarify some things before I start fixing them?

1. You want the entire message gone, or just the brackets?
4. Core already had an empty line there to separate the different token types, I see no harm in having them?
5. No, but if we always remove the first 6 letters, the active-theme token would break, so we only remove them if the token starts with it. (If you have a better option, please share as I too feel this is a bit hackish.)
6. What default description is missing?
7. I'll try
8. Earlier I had problems with provided and required token types; eg. the 3rd parameter would always be a theme, this is a leftover of that. Ideally you don't want [site:logo] to be used either as the other options are more predictable. But I do not believe I can block it.

plach’s picture

1: Just the brackets, thanks!
4: The existing space was not supposed to be there: https://www.drupal.org/docs/develop/standards/coding-standards#controlst... :)
5: Oh, I see, all good then
6: Optional parameters should always have a description of the default behavior, i.e. what happens when the parameter is not specified, if it's not obvious. In this case it would be something like: By default a URL is returned.
8: Got it, thanks

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new33.79 KB
new24.44 KB

Here you go :)

Status: Needs review » Needs work

The last submitted patch, 82: token_for_site_logo-2842780-82.patch, failed testing. View results

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new33.79 KB

Rebased

Status: Needs review » Needs work

The last submitted patch, 84: token_for_site_logo-2842780-84.patch, failed testing. View results

neograph734’s picture

Apparently I should not be working anymore... I'll fix it tomorrow.

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new16.72 KB

It seems my character encoding was off. Lets try it like this.
Interdiff is in #82.

plach’s picture

Status: Needs review » Needs work

Thanks, we are very close to RTBC!

  1. +++ b/core/modules/system/system.tokens.inc
    @@ -18,6 +19,16 @@ function system_token_info() {
    +    'name' => t("Site logo"),
    +    'description' => t("Tokens related to the site logo."),
    +    'needs-data' => 'site',
    

    (here and below) Can we stick to single quotes for consistency?

  2. +++ b/core/modules/system/system.tokens.inc
    @@ -49,6 +60,42 @@ function system_token_info() {
    +  // Logo related tokens.
    +  $site_logo['active-theme'] = [
    

    [logo:url] is not defined in the token info.

  3. +++ b/core/modules/system/system.tokens.inc
    @@ -192,3 +297,53 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +  $logo_url = theme_get_setting('logo.url', $theme) ?: theme_get_setting('logo.url', $default_theme);
    ...
    +  return Url::fromUserInput($logo_url, ['absolute' => TRUE])->toString();
    

    Can we store the absolute URL in $logo_url so that also the rendered image gets it?

  4. +++ b/core/modules/system/system.tokens.inc
    @@ -192,3 +297,53 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +  // @todo: We might be able to use the relative $logo_url variable once https://www.drupal.org/project/drupal/issues/2704597 is complete.
    

    This comment does not wrap at column 80 properly.

neograph734’s picture

Thanks for reviewing plach.

1. Yes, possible. But should I also adapt all other tokens? The original site and date tokens do it like this as well.
I'll change the rest.

plach’s picture

I wouldn't touch the other token definitions, just the ones introduced by this patch. We just need to ensure the new code is consistent :)

  1. +++ b/core/modules/system/system.tokens.inc
    @@ -192,3 +297,53 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +  $config = \Drupal::config('system.theme.global');
    +  $system_theme_config = \Drupal::config('system.theme');
    

    We need to add also these two to bubbleable metadata, I think, as global settings and the default theme may change, which would require cached logo token values to be invalidated.

  2. +++ b/core/modules/system/system.tokens.inc
    @@ -192,3 +297,53 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +  $theme_config = \Drupal::config($theme . '.settings');
    +  $bubbleable_metadata->addCacheableDependency($config);
    +  $bubbleable_metadata->addCacheableDependency($theme_config);
    

    Now that I think about it, in the case of the active-theme we also need to manually add the theme cache context, otherwise if logo tokens are used in cacheable contexts, e.g. node bodies, the active theme will be cached and subsequent request may get the wrong theme.

neograph734’s picture

I think I have got figured out like this:

  // Retrieve configurations.
  $system_theme_config = \Drupal::config('system.theme');
  $default_theme = $system_theme_config->get('default');

  if ($theme == 'default-theme') {
    $theme = $default_theme;
    $bubbleable_metadata->addCacheableDependency($system_theme_config);
  }
  elseif ($theme == 'active-theme') {
    $theme = \Drupal::service('theme.manager')->getActiveTheme()->getName();
    $bubbleable_metadata->addCacheContexts(['theme']);
  }

  $config = \Drupal::config('system.theme.global');
  $theme_config = \Drupal::config($theme . '.settings');
  $bubbleable_metadata->addCacheableDependency($config);
  $bubbleable_metadata->addCacheableDependency($theme_config);

  // If there is no logo, we use the default theme as fallback.
  $logo_path = theme_get_setting('logo.url', $theme) ?: theme_get_setting('logo.url', $default_theme);

theme_get_setting can use either the global config or a theme specific implementation, so we need both configs. Only the default theme depends on system.theme, and active comes with a cache context.

Regarding #88-2, It is more or less in line with #80-8. site:logo renders the active theme logo, so site:logo:url should return the active theme url. But that also already had a dedicated token. I think it would be better to not actively promote it, as the dedicated tokens are more predictable.

plach’s picture

#91 looks good to me, thanks!

Regarding #88-2, It is more or less in line with #80-8. site:logo renders the active theme logo, so site:logo:url should return the active theme url. But that also already had a dedicated token. I think it would be better to not actively promote it, as the dedicated tokens are more predictable.

If a token is not defined in token info, it cannot be validated, so it cannot be used wherever token validation is applied, e.g. user mail notification settings. If you strongly feel it shouldn't be promoted, then we should revert the change for #80.8 and not provide a replacement for it. The current state is confusing and inconsistent IMO :)

neograph734’s picture

Assigned: Unassigned » neograph734

Self assigning. I am in the process of reworking the tests, so we can proper test if all tokens work. (I had some doubts on the active token test, and frankly the current test is quite messy.) I will implement some switches in active theme and default theme config and see if the tokens follow as expected.

It should be done by the end of this week.

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new16.66 KB
new43.91 KB

I think this includes all discussed changes. Double quotes have been replaced by single ones, the site:logo:url token has been removed. And the tests have been cleaned up and are readable now.

However that are a few things I ran into.

  $logo_url = Url::fromUserInput($logo_path, ['absolute' => TRUE])->toString();

  $build = [
    '#theme' => 'image',
    '#uri' => $logo_url,
  ];
  return \Drupal::service('renderer')->renderPlain($build);

This returns an image using the local path only: <img src="/path/to/file">, rather than <img src="http://example.com/path/to/file">

I cannot get the test to fail. I'd expect that removing all cacheable dependencies from _system_tokens_get_actual_logo (and disabling their assertions in TokenReplaceKernelTest) would break, because the system should serve the same token again rather than recreate it (the metadata did not change). However all tokens output as expected.

Test it like this:

function _system_tokens_get_actual_logo($theme, BubbleableMetadata &$bubbleable_metadata, $render = FALSE) {
  // Retrieve configurations.
  $system_theme_config = \Drupal::config('system.theme');
  $default_theme = $system_theme_config->get('default');

  if ($theme == 'default-theme') {
    $theme = $default_theme;
//    $bubbleable_metadata->addCacheableDependency($system_theme_config);
  }
  elseif ($theme == 'active-theme') {
    $theme = \Drupal::service('theme.manager')->getActiveTheme()->getName();
//    $bubbleable_metadata->addCacheContexts(['theme']);
  }

  $global_config = \Drupal::config('system.theme.global');
  $theme_config = \Drupal::config($theme . '.settings');
//  $bubbleable_metadata->addCacheableDependency($global_config);
//  $bubbleable_metadata->addCacheableDependency($theme_config);

  // If there is no logo, we use the default theme as fallback.
  $logo_path = theme_get_setting('logo.url', $theme) ?: theme_get_setting('logo.url', $default_theme);

  // @todo: We might be able to use the relative $logo_path variable once
  // https://www.drupal.org/project/drupal/issues/2704597 is complete. Currently
  // this is required to make the tokens work in e-mails.
  $logo_url = Url::fromUserInput($logo_path, ['absolute' => TRUE])->toString();

  if ($render) {
    $build = [
      '#theme' => 'image',
      '#uri' => $logo_url,
    ];
    return \Drupal::service('renderer')->renderPlain($build);
  }

  return $logo_url;
}

And use this for any of the tests.

      foreach ($tests as $input => $expected) {
        $bubbleable_metadata = new BubbleableMetadata();
        $output = $this->tokenService->replace($input, [], [], $bubbleable_metadata);
        $this->assertEquals($expected, $output, new FormattableMarkup('System site information token %token replaced.', ['%token' => $input]));
        //$this->assertEquals($metadata_tests[$input], $bubbleable_metadata, new FormattableMarkup('Asserting metadata for token %token.', ['%token' => $input]));
      }

Howcome?

tr’s picture

However that are a few things I ran into.

  $logo_url = Url::fromUserInput($logo_path, ['absolute' => TRUE])->toString();

  $build = [
    '#theme' => 'image',
    '#uri' => $logo_url,
  ];
  return \Drupal::service('renderer')->renderPlain($build);

This returns an image using the local path only: <img src="/path/to/file">, rather than <img src="http://example.com/path/to/file">

Yes, this is what I said in #73 above, as well as two years ago in the issue that broke this: #1494670-121: References to CSS, JS, and similar files should be root-relative URLs: avoids mixed content warnings & fewer bytes to send.

If you use '#theme' => 'image' you will ALWAYS get a relative path for a local image, even if you specify 'absolute' => TRUE.

The only way to get an absolute URL right now is to explicitly write out the link as markup:

  $logo_url = Url::fromUserInput($logo_path, ['absolute' => TRUE])->toString();

  $build = [
    '#markup' => '<img src="' . $logo_url . '" />',
  ];

This is not a great solution, because then you don't get the attributes in the img tag that would normally be added by the theme function, but at least you get a working link.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xjm’s picture

Issue tags: -String change in 8.5.0

Please only tag string changes after the issue is actually committed. Thanks!

neograph734’s picture

Assigned: neograph734 » Unassigned

Converting relative mails to full ones is covered in #2704597: Relative URLs in mails should be converted to absolute ones.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mgoncalves’s picture

I was testing the patch #94 and faced an situation.

All my files (including Logo) are being saved on CDN. When I try to see the logo information replaced by token, the following message is delivered on my screen.
"This image has been removed. For security reasons, only images from the local domain are allowed."

Is it the behavior expected ?

Thank you all.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

stomusic’s picture

StatusFileSize
new16.49 KB

Patch #94 updated for Drupal 8.7

alonaoneill’s picture

Patch applied on 8.8.

othmen’s picture

patch #94 applied and worked for D 8.6.16

john cook’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll, +Novice

The patch in #102 needs a re-roll for the 8.8.x branch. So I've set the "needs reroll" and "novice" tags for this task.

yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar
joshi.rohit100’s picture

Issue tags: +#DCD19

Adding tag for DCD 2019 code sprint.

yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll, -Novice
StatusFileSize
new16.36 KB

Re-rolled patch for #102.

anybody’s picture

#2704597: Relative URLs in mails should be converted to absolute ones is fixed now (mentioned in patch #108 as comment).

tr’s picture

StatusFileSize
new16.51 KB

#108 can't be RTBC because it doesn't even apply, "PHP 7.1 & MySQL 5.7 PHPLint Failed". You can't even try it out on your site without fixing this first.

The reason it fails to apply is a duplicate "use" statement in TokenReplaceKernelTest.php

Here is a new patch identical to #108 but with that duplicate "use" statement removed. I have NOT evaluated this patch to see if it solves the issue, this is just a re-roll to make the patch apply so the testbot can look at it and so it can be reviewed here.

mpp’s picture

Can/Should we also add a token for the admin theme?

Some nitpicks, mostly double quotes where we should use single quotes:

  1. +++ b/core/modules/system/system.tokens.inc
    @@ -19,6 +19,16 @@ function system_token_info() {
    +    'name' => t("Site logo"),
    

    Use single quotes.

  2. +++ b/core/modules/system/system.tokens.inc
    @@ -19,6 +19,16 @@ function system_token_info() {
    +    'description' => t("Tokens related to the site logo."),
    

    Use single quotes.

  3. +++ b/core/modules/system/system.tokens.inc
    @@ -19,6 +19,16 @@ function system_token_info() {
    +    'name' => t("Site logo properties"),
    

    Use single quotes.

  4. +++ b/core/modules/system/system.tokens.inc
    @@ -19,6 +19,16 @@ function system_token_info() {
    +    'description' => t("Tokens for site logo properties."),
    

    Use single quotes.

  5. +++ b/core/modules/system/system.tokens.inc
    @@ -53,6 +63,42 @@ function system_token_info() {
    +    'description' => t('The logo of the active theme. Pay attention when using this from the administrative interface, as the theme might be different.'),
    

    The logo of the active theme. Note that the administration theme may have a different logo.

  6. +++ b/core/modules/system/system.tokens.inc
    @@ -53,6 +63,42 @@ function system_token_info() {
    +        'description' => t('The logo for the %theme theme.', ['%theme' => $info->info['name']]),
    

    'description' => t('The logo for the %theme theme.', [
    '%theme' => $info->info['name'],
    ]),

  7. +++ b/core/modules/system/system.tokens.inc
    @@ -196,3 +299,57 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +  if ($theme == 'default-theme') {
    

    ===

  8. +++ b/core/modules/system/system.tokens.inc
    @@ -196,3 +299,57 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +  elseif ($theme == 'active-theme') {
    

    ===

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

dqd’s picture

I am confused ... what has troubled me a lot since ages was that the logo always relied on theme settings only, but not on basic site info configuration settings as a general override, where users type in the name and the slogan. So does this token will change the logo path regarding the theme used when the token is present? Doesn't it cause cache issues? Especially when the theme changes under certain conditions? What about contrib modules which change logo under certain conditions or themes which use more than one logo for different styles (mobile, etc.?)...

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mayurgajar’s picture

Assigned: Unassigned » mayurgajar
Status: Needs review » Reviewed & tested by the community

Hi @ TR

patch #110 file : 2842780-110.patch apply cleanly LGTM +1 RTBC .

Thanks..!!!

dqd’s picture

So does this token will change the logo path regarding the theme used when the token is present? Doesn't it cause cache issues? Especially when the theme changes under certain conditions? What about contrib modules which change logo under certain conditions or themes which use more than one logo for different styles (mobile, etc.?)...

I still think this considerations are not obsolete yet. Would love to get some thoughts on it to let it go ...

@#115: Thanks for reviewing and reporting. But... I copied the paragraph from the OT for you. Do you have done precisely what has been listed here before setting it RTBC? Please provide more details in your review. Thanks.

Steps to reproduce:
- without applying patch, install and enable 'token' module (so you can easily browse the list of available tokens)
- edit Article content type, go to manage fields, edit Body
- click "Browse available tokens" link underneath Help text, to open Available tokens popup
- verify no site logo tokens in the Site information list

- now apply patch
- drush cr
- reload Available tokens popup, verify [site:logo] and [site:logo-url] added
- insert them into help text and create or edit an article to verify the Drupal logo and standard URL (/core/themes/bartik/logo.svg) are now visible
- configure a different logo for another theme (seven)
- insert [site:logo:seven] and [site:logo-url:seven] to have the logo show up.
- [site:logo:non-existing-theme] should not be replaced

dqd’s picture

Assigned: mayurgajar » Unassigned

And for @#115: again: Apart from that please do not assign the issue to yourself while setting it RTBC. (It maybe happend accidently.) Just to let you know.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for proposing this feature. Since it is a new feature, I'm moving it to the 9.1.x development branch. I also queued a test against 9.1.x.

It looks like #111 could still be addressed. I also had a quick look at the patch myself and noticed a couple things. (Haven't done a full review.)

  1. +++ b/core/modules/system/system.tokens.inc
    @@ -196,3 +299,57 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    + * @param $theme
    + *   The theme to load the logo for.
    

    This is missing a data type.

  2. +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
    @@ -2,11 +2,11 @@
    -use Drupal\Core\Url;
     use Drupal\Component\Render\FormattableMarkup;
     use Drupal\Component\Utility\Html;
     use Drupal\Component\Utility\Xss;
     use Drupal\Core\Render\BubbleableMetadata;
    +use Drupal\Core\Url;
    

    Out-of-scope change.

  3. +++ b/core/modules/system/system.tokens.inc
    @@ -53,6 +63,42 @@ function system_token_info() {
    +    'description' => t('The logo of the active theme. Pay attention when using this from the administrative interface, as the theme might be different.'),
    

    "Pay attention" seems a bit adversarial. Maybe:

    Note that the theme may be different when this is used in the administrative interface.

  4. +++ b/core/modules/system/system.tokens.inc
    @@ -53,6 +63,42 @@ function system_token_info() {
    +  // Theme specific logo tokens.
    

    Nit: Theme-specific.

  5. +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
    @@ -129,6 +129,188 @@ public function testSystemSiteTokenReplacement() {
    +   * @return array
    

    Can we more specifically describe the data type of the array? It is maybe array[] or string[][] or mixed[][] depending on the data structure of the returned config -- we could check the called method to see exactly how the data is structured.

kishor_kolekar’s picture

Assigned: Unassigned » kishor_kolekar
kishor_kolekar’s picture

Status: Needs work » Needs review
StatusFileSize
new16.64 KB
new3.35 KB

Addressed #111 and #118
please review the patch.

kishor_kolekar’s picture

Assigned: kishor_kolekar » Unassigned
IhorMaster’s picture

StatusFileSize
new1.09 KB

Hello everyone!

I had the same issue with creating a token of site logo and tried to use patches from this topic. But into all of them use function theme_get_setting() and this function is deprecated in Drupal 8.7 and Drupal 9.
So I created new patch without function theme_get_setting(). I have tested this path with different themes and all ok for me.

Please, check my patch.

neograph734’s picture

Hi Ihor,

Your patch is removing a lot of functionality that was added before, which has all been addressed in this issue. There is a patch for Drupal 8.8 in #110, in which you could have simply replaced theme_get_setting?

But since this is feature request, it should be tested against 9.1 as xjm explained in #118 (and there is a patch in #120). Once it is in Drupal 9, we can focus on the backport to 8.
If you want to help push this issue forward, please help testing the patch from #120 with Drupal 9.

samiullah’s picture

Applied the patch #122 on drupal 9.1x
Was able to see site logo token

If there is more code review needed, after that it can be moved to RTBC

neograph734’s picture

Hi samiullah, please review #120, which is much more complete. Thanks

samiullah’s picture

@neograph that one looks better. Probably a code review is needed before we can move it to RTBC

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

neograph734’s picture

Status: Needs review » Needs work

Well, I had a fresh look and I found some strange things that should be looked into.
Feedback on the patch from #120.

  1. +++ b/core/modules/system/system.tokens.inc
    @@ -53,6 +63,44 @@ function system_token_info() {
       /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
       $date_formatter = \Drupal::service('date.formatter');
    

    Let's move this below all logo tokens and just before the date tokens where it is used.

  2. +++ b/core/modules/system/system.tokens.inc
    @@ -53,6 +63,44 @@ function system_token_info() {
    +  // Chained tokens for site-wide settings and other global information.
    +  $site['logo'] = [
    +    'name' => t('Logo'),
    

    This comment does not really match the token.

  3. +++ b/core/modules/system/system.tokens.inc
    @@ -53,6 +63,44 @@ function system_token_info() {
    +  // Theme specific .
    +  $site_logo_properties['url'] = [
    

    Site logo property tokens.

  4. +++ b/core/modules/system/system.tokens.inc
    @@ -196,3 +301,57 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +  // If there is no logo, we use the default theme as fallback.
    +  $logo_path = theme_get_setting('logo.url', $theme) ?: theme_get_setting('logo.url', $default_theme);
    

    Since the patch evolved and we have much more control over the selected theme, this fallback makes no sense anymore (perhaps it never did). It can even lead to unexpected behavior. Besides, theme_get_setting() already defaults to the global configuration if the theme does not provide one.

    I think this should be enough:
    $logo_path = theme_get_setting('logo.url', $theme)

  5. +++ b/core/modules/system/system.tokens.inc
    @@ -196,3 +301,57 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +  // @todo: We might be able to use the relative $logo_path variable once
    +  // https://www.drupal.org/project/drupal/issues/2704597 is complete. Currently
    +  // this is required to make the tokens work in e-mails.
    +  $logo_url = Url::fromUserInput($logo_path, ['absolute' => TRUE])->toString();
    

    This issue is closed by now, so let's make use of it. For the images, relative paths should be save to use again. SystemBrandingBlock does it like this:

        $build['site_logo'] = [
          '#theme' => 'image',
          '#uri' => theme_get_setting('logo.url'),
          ...
        ];

    However for the URLs we should still make use of the absolute path (I can not imagine a use case for a relative path as token). So it could become something like this:

      $logo_path = theme_get_setting('logo.url', $theme);
    
      if ($render) {
        $build = [
          '#theme' => 'image',
          '#uri' => $logo_path,
        ];
        return \Drupal::service('renderer')->renderPlain($build);
      }
    
      return Url::fromUserInput($logo_path, ['absolute' => TRUE])->toString();
  6. +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
    @@ -2,15 +2,16 @@
    - * Generates text using placeholders for dummy content to check token
    - * replacement.
    + * Generates text using placeholders for dummy content to check token.
    + *
    + * To check token replacement.
    

    This now feels like two unrelated sentences. Besides, I think it would be out of scope for this patch.

  7. +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
    @@ -128,6 +129,188 @@ public function testSystemSiteTokenReplacement() {
    +    foreach ($subsequent_tests as $testdata) {
    ...
    +    foreach ($subsequent_tests as $testdata) {
    ...
    +    foreach ($subsequent_tests as $testdata) {
    

    Do we really have to test that the active and default theme tokens work for both bartik and seven coming from $subsequent_tests? Even for the testSystemSiteLogoThemeTokenReplacement I think one theme might be enough? (Also see next comment)

  8. +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
    @@ -128,6 +129,188 @@ public function testSystemSiteTokenReplacement() {
    +  /**
    +   * Prepares configurations and returns themes and configurations to test.
    +   *
    +   * @return array
    +   *   An array of theme and configuration pairs.
    +   */
    +  public function systemSiteLogoTokensData() {
    +    // Install Bartik and Seven.
    +    \Drupal::service('theme_installer')->install(['bartik']);
    +    \Drupal::service('theme_installer')->install(['seven']);
    +
    +    // Set the global configuration.
    +    $config['global'] = $this->config('system.theme.global');
    +    $config['global']
    +      ->set('logo.path', '/path/to/global_logo.svg')
    +      ->set('logo.use_default', FALSE)
    +      ->save();
    +
    +    // Set the Seven configuration.
    +    $config['bartik'] = $this->config('bartik.settings');
    +    $config['bartik']
    +      ->set('logo.path', '/path/to/bartik_logo.svg')
    +      ->set('logo.use_default', FALSE)
    +      ->save();
    +
    +    // Set the Seven configuration.
    +    $config['seven'] = $this->config('seven.settings');
    +    $config['seven']
    +      ->set('logo.path', '/path/to/seven_logo.svg')
    +      ->set('logo.use_default', FALSE)
    +      ->save();
    +
    +    return [
    +      ['bartik', $config],
    +      ['seven', $config],
    +    ];
    +  }
    +
    

    This is an odd one. It was supposed to be a data provider, but it also does things.
    I think installing one theme and one configuration (removing the need for foreach in the above comment) should be enough and can be handled within the three tests themselves. (Or test during test setup).

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new15.2 KB
new19.56 KB

Well, I just did one round of cleanups. Tests are combined to 2 and the awkward data provider has been removed. Furthermore it made more sense to use file_create_url() instead of Url::fromUserInput($logo_path, ['absolute' => TRUE])->toString().

When testing, please also include it in an email to verify that #2704597: Relative URLs in mails should be converted to absolute ones indeed works.

Thanks for all effort so far. Let's make sure this makes it into Drupal 9.2 :)

Status: Needs review » Needs work

The last submitted patch, 129: 2842780-129.patch, failed testing. View results

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new15.21 KB
new1.14 KB

Using assertStringContainsString instead of assertContains for string comparison...

Status: Needs review » Needs work

The last submitted patch, 131: 2842780-131.patch, failed testing. View results

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new15.14 KB
new3.81 KB

Perhaps I should not do these things that late..

The change file_create_url() instead of Url::fromUserInput($logo_path, ['absolute' => TRUE])->toString() was passing all test, but resulted in a root relative URL, not an absolute one. So I had to revert that change.
Apart from that, I think this is much cleaner than what I originally built.

Patch has been tested with emails, and I can confirm that #2704597: Relative URLs in mails should be converted to absolute ones works. It was however a bit tricky to get it working as that patch only acts on markup (so you cannot use the account created/cancelled/ etc mail). So In the end I used token_filter, simplenews and swiftmailer to include it in a newsletter (make sure that you enable HTML for both swiftmailer, simplenews and the newsletter bundle).

Followup issue to make this display everywhere #2855653: FilterHtmlImageSecure filters out valid local svg images.

abhijith s’s picture

StatusFileSize
new54.63 KB
new112.57 KB
new32.29 KB

Applied patch #133 .It works fine. There will be tokens available for site logo and site logo url after installing this patch.

Including screenshots
before patch:
before

after patch(tokens available):
after1

after patch(tokens output):
after2

RTBC

paulocs’s picture

StatusFileSize
new14.92 KB
new2.07 KB

Fixing Drupal code standard.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

neograph734’s picture

Status: Needs review » Reviewed & tested by the community

Patch still applies to 9.3. Back to RTBC based on #134.

alexpott’s picture

  1. +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
    @@ -128,6 +128,146 @@ public function testSystemSiteTokenReplacement() {
    +    $tests['[site:logo]'] =
    +    $tests['[site:logo:active-theme]'] = $seven_logo;
    

    This looks really odd. Yes it is equivalent to

    $tests['[site:logo]'] = $tests['[site:logo:active-theme]'] = $seven_logo;
    

    but I don't think the changing it to this is really worth it.

    How about being explicit and doing...

      $tests['[site:logo]'] = $seven_logo;
      $tests['[site:logo:active-theme]'] = $seven_logo;
    
  2. +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
    @@ -128,6 +128,146 @@ public function testSystemSiteTokenReplacement() {
    +    $metadata_tests['[site:logo]'] =
    +    $metadata_tests['[site:logo:active-theme]'] =
    +    $metadata_tests['[site:logo:active-theme:url]'] = BubbleableMetadata::createFromObject($global_theme_config)
    +      ->addCacheableDependency($seven_config)
    +      ->addCacheContexts(['theme']);
    +    $metadata_tests['[site:logo:default-theme]'] =
    +    $metadata_tests['[site:logo:default-theme:url]'] = BubbleableMetadata::createFromObject($global_theme_config)
    +      ->addCacheableDependency($bartik_config)
    +      ->addCacheableDependency($system_theme_config);
    

    Ahhh I see you're doing the same here. I can see the benefit here but it still looks really odd. Do we have other examples of this format in core?

    Earlier in the same test we do

        $metadata_tests = [];
        $metadata_tests['[site:name]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
        $metadata_tests['[site:slogan]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
        $metadata_tests['[site:mail]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
        $bubbleable_metadata = clone $base_bubbleable_metadata;
        $metadata_tests['[site:url]'] = $bubbleable_metadata->addCacheContexts(['url.site']);
        $metadata_tests['[site:url-brief]'] = $bubbleable_metadata;
        $metadata_tests['[site:login-url]'] = $bubbleable_metadata;
    

    Which, to me, looks as readable and less surprising than what's in the patch.

    The multiple assignments were introduced in #94 and have not yet been discussed in the comments as far as I can see.

    I'm not really sure... about this going to leave at RTBC and solicit more opinion.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Discussed with #138 with @catch and neither of us are particularly keen on multi-line multiple assignments. Let's see if there's another way of doing this.

AnnaE1990’s picture

StatusFileSize
new139.35 KB

I'm using a modified Bootstrap Barrio 8.x-4.28 theme. in the registration e-mail of the new user the website logo should appear but it looks:

"

img src="/sites/default/files/logo2.0_1.png" alt="" typeof="foaf:Image"

AnnaEjankowska

Dziękujemy za rejestrację na stronie e-jankowska. Twoja prośba o utworzenie konta oczekuje na zatwierdzenie. Po zatwierdzeniu otrzymasz kolejny e-mail zawierający informacje o tym, jak się zalogować, ustawić hasło i inne szczegóły.

-- Zespół e-jankowska
"
instead of the displayed image.
I use the swift mailer to send e-mails.
core drupal 9.2 PHP 7.4
a screenshot of the settings for shipping.
How to fix this issue?

tr’s picture

(You need to format your post with the "code" formatting so drupal.org displays the raw output without the HTML tags escaped.)

@AnnaE1990: Drupal core does not directly support HTML email, that functionality is provided by contributed modules. If your email is not displaying the HTML correctly that's a problem with the contributed module you're using (swiftmailer). That's unrelated to this issue. If you type in an image tag directly instead of using the token you would see the same result.

This issue is about making the token available and making sure the token has the right value. I think your post is saying the token has the value <img src="/sites/default/files/logo2.0_1.png" alt="" typeof="foaf:Image">, which appears to be basically correct except it's a relative URL instead of absolute. I raised this as a major problem more than 3 years ago in #73, and I'm disappointed that this problem hasn't been addressed yet.

AnnaE1990’s picture

there is a fresh module, and its working fine https://www.drupal.org/project/simple_html_mail

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new15.67 KB
new4.46 KB

Implemented the feedback from #138 and #139. Added some empty arrays to better match with the other tests too.

Status: Needs review » Needs work

The last submitted patch, 143: 2842780-143.patch, failed testing. View results

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new15.61 KB
new3.65 KB

Obviously that was all just stacking up instead of starting from scratch. I think this is better to understand rather then a whole bunch of clones.

darvanen’s picture

+++ b/core/modules/system/system.tokens.inc
@@ -196,3 +301,52 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
+ * @param bool $render
+ *   (Optional) If this is set to TRUE, this function will return a rendered
+ *   logo. It will return an URL to the logo otherwise.

This is powerful.

Is there a way we can make this a more systemic change?

(Note: I'm still familiarising myself with the deeper token sysetms)

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

To push things forward here and as @alexpott's comments from #138 have been addressed in #145 settings this RTBC.

Any further thoughts or issues? Otherwise, I think we could try to finish this nice feature after > 5 years? :)

LGTM!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 145: 2842780-145.patch, failed testing. View results

anybody’s picture

Status: Needs work » Needs review
neograph734’s picture

StatusFileSize
new15.61 KB

I think the order of cache tags has changed, so the array is no longer an exact match. Adding a patch with a changed order just to be sure. (Changes the order in lines 281 - 283).

anybody’s picture

Status: Needs review » Needs work

Thanks @Neograph734, yes indeed. Could you please include an interdiff to be sure? Thanks!

neograph734’s picture

I think it is a bit more complicated than initially assumed. I think this is no longer applying because Bartik has been replaced by Olivero... So some more time is needed for a proper reroll.

neograph734’s picture

StatusFileSize
new27.11 KB

Let's see what this does.

neograph734’s picture

Status: Needs work » Needs review
neograph734’s picture

StatusFileSize
new13.29 KB

Funny how these patches do apply locally... :s

Status: Needs review » Needs work

The last submitted patch, 157: 2842780-157.patch, failed testing. View results

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new15.66 KB
new9.33 KB

It turns out that all instances of REQUEST_TIME have been updated. This was causing 152 to fail. No other big changes have been done. Nevertheless, now all occurences of Bartik and Seven have been updated to be Olivero and Claro instead.

neograph734’s picture

Status: Needs review » Reviewed & tested by the community

Awesome!

No significant changes, as can be seen in the interdiff. Restoring the RTBC from #149.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/system/system.tokens.inc
    @@ -50,6 +60,44 @@ function system_token_info() {
    +  // Token [site:logo] renders the active theme logo. Nesting for more options.
    

    What does "Nesting for more options." mean?

  2. +++ b/core/modules/system/system.tokens.inc
    @@ -152,10 +202,65 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +      $name = (stripos($name, 'theme-') === 0) ? substr($name, 6) : $name;
    

    $name = str_starts_with($name, 'theme-') ? substr($name, 6) : $name;

    Easier to read and with have PHP 8 polyfill on D9.

  3. +++ b/core/modules/system/system.tokens.inc
    @@ -197,3 +302,52 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
    +  if ($render) {
    +    $build = [
    +      '#theme' => 'image',
    +      '#uri' => $logo_url,
    +    ];
    +    return \Drupal::service('renderer')->renderPlain($build);
    +  }
    +  return Url::fromUserInput($logo_url, ['absolute' => TRUE])->toString();
    

    I think we should have one function to get the logo url for the provided theme and another function to get the rendered logo.

    I'm also not convinced that we should renderPlain here. I think we want a markup object so the token system knows this is markup and does the right thing with it in different contexts. See #2580723: Fix token system confusion, with new function Token::replacePlain() for more about this.

    I also wonder what we should do for accessibility. I think the rendered image should have alt text.

alexpott’s picture

+++ b/core/modules/system/system.tokens.inc
@@ -197,3 +302,52 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
+function _system_tokens_get_actual_logo($theme, BubbleableMetadata &$bubbleable_metadata, $render = FALSE) {

We should use primitive typehints here...
_system_tokens_get_actual_logo(string $theme, BubbleableMetadata &$bubbleable_metadata, bool $render = FALSE) {

Also the _actual in the function name does seem to add anything to me.

Also See above - I think this function should be split into two functions so the return value is consistent.

Plus we should be using return typehints too.

pradhumanjain2311’s picture

Assigned: Unassigned » pradhumanjain2311
pradhumanjain2311’s picture

Assigned: pradhumanjain2311 » Unassigned
StatusFileSize
new15.47 KB
new776 bytes

@alexpott i add primitive typehints in _system_tokens_get_actual_logo function as per your comment #162.
But other changes like function should be split into two functions so the return value is consistent.
Plus we should be using return typehints still remains.

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new16 KB
new6.12 KB

@alexpott feedback addressed. I am only not sure what you meant with this:

I'm also not convinced that we should renderPlain here. I think we want a markup object so the token system knows this is markup and does the right thing with it in different contexts. See #2580723: Fix token system confusion, with new function Token::replacePlain() for more about this.

\Drupal::service('renderer')->renderPlain returns a MarkupInterface object, so that should be good right? I'd like to remain as close as possible to what is happening in SystemBrandingBlock::build().

neograph734’s picture

StatusFileSize
new16.04 KB

Status: Needs review » Needs work

The last submitted patch, 166: 2842780-166.patch, failed testing. View results

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new16.1 KB
new1.18 KB

Ah, I thought I had only changed the function signatures so the test should still apply. But the alt attribute had to be added to the test as well.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nod_’s picture

Status: Needs review » Needs work

The logo is not defined in the site settings (as in, on the /admin/config/system/site-information page).

The token should probably be [theme:logo] instead of [site:logo:...], it will avoid having to do the default-theme/admin-theme dance.

neograph734’s picture

I think that would make it even more unpredictable. What theme will be used in such case? And the site token is already an exsiting container. As I user I would expect to find the logo there.

nod_’s picture

Status: Needs work » Needs review
Issue tags: +Needs subsystem maintainer review
darvanen’s picture

With regards to #170 vs #171:

The description of the site token type is

Tokens for site-wide settings and other global information.

As the logo is not a site-wide setting I believe this token falls outside of the scope for that token type.

Having a token type specifically for the logo seems rather restrictive, and though there are some examples of single-purpose token types I think the introduction of a [theme] token type would be more extensible.

My vote would be for this kind of structure:

  • [theme (active/current theme)
  • [theme:default
  • [theme:admin
  • [theme:theme_name

to which you could add any of the following suffixes:

  • :logo] (rendered markup)
  • :logo:image_url]
  • :logo:alternate_text]

and provides the capacity to access such things as favicons and breakpoint settings IF such things were deemed necessary to be accessed by non-developer site builders and users.

This is a big scope change though, and the introduction of a new token type in core is not to be taken lightly. If the above structure were accepted it may be best to move this effort to the token module instead.

So, questions:

  1. Can anyone see *any* use-case for accessing other theme-related information such as favicon via tokens?
  2. If yes, can you see any other logical way of presenting that information?
tr’s picture

This is a big scope change though, and the introduction of a new token type in core is not to be taken lightly. If the above structure were accepted it may be best to move this effort to the token module instead.

Oh come on. This is a long standing REGRESSION - we used to have a site token for the logo in D7 and this was left out of core when the Token module was partially merged into core. It's lost functionality, not a "new token type". It shouldn't take 5 years to restore that lost functionality, and you're not helping by throwing a monkey wrench into the process.

nod_’s picture

Status: Needs review » Postponed
Issue tags: +Needs maintainer

I can understand both points of view here.

The main problem to me is that there is no module maintainer that can make the call and live with it afterwards by providing support/guidance on what to do on the long term.

I don't have any skin in this issue and while it's unfortunate that it probably means this issue will stall I'm postponing it on the fact that there is no maintainer for the module.

If someone really wants this to move along I think the only solution is starting to look at the token queue and applies for maintainership of the module. I can't help maintain the module but I can help navigate the process so anyone is up for it and wants to talk about it, feel free to ping me :)

berdir’s picture

Status: Postponed » Needs review

No need to get emotional but I do agree that this doesn't need a new token type. The proposed structure doesn't work quite work, you can't have theme be two different things and a token that then depends on the current theme is just as global as "site".

I don't think we postpone single issues over not having a maintainer. This has been RTBC, and there was core maintainer feedback from @alexpott in #161, someone needs to verify that this has been addressed and if yes, can be set back to RTBC.

adamps’s picture

Tokens for site-wide settings and other global information. As the logo is not a site-wide setting I believe this token falls outside of the scope for that token type.

That's a very interesting point.

On the other hand, may of the existing tokens such as [node:body] have output that depends on theme. In these cases, the current theme is used. Every part of the page even is rendered in the current theme - which can be switched if needed. If we describe the logo token as "the logo from the current theme" then arguably it is global information. It's not really clear me what the use case is for displaying the logo from a different theme when everything else is from the current theme.

I feel there are good reasons for sticking with the simpler [site:logo]. It's easier to understand, it avoids creating a new token type, and it matches the way it worked in D7.

gaurav-mathur’s picture

Assigned: Unassigned » gaurav-mathur
gaurav-mathur’s picture

Assigned: gaurav-mathur » Unassigned
StatusFileSize
new66.74 KB
new31.56 KB

Patch #168 applied successfully on Drupal 10.1.x-dev.
The patch work properly for me.
Refer to screenshots.

darvanen’s picture

Status: Needs review » Needs work

Consider me convinced.

I have reviewed the patch against the feedback in #161 and #162.

  • 161.1 - Done
  • 161.2 - Done
  • 161.3 - Per #165 I think there's some confusion between renderPlain and replacePlain happening here. The code as provided does return a Markup object.

162 is complete except for:

Plus we should be using return typehints too.

which means this needs to go back to NW for that. So while I'm doing that I'll note one nit:

+++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
@@ -2,11 +2,11 @@
 namespace Drupal\Tests\system\Kernel\Token;
 
-use Drupal\Core\Url;
 use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Render\BubbleableMetadata;
+use Drupal\Core\Url;
 

As much I would prefer to do this kind of cleanup as we go, core committers seem pretty strict around not including unrelated changes (I think it's a slippery slope problem, I can see where it could become a problem).

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

anybody’s picture

This needs a reroll against 11.x-dev now. #168 doesn't apply against 10.1.x for me?!

rpayanm made their first commit to this issue’s fork.

rpayanm’s picture

Title: Add a token for the site logo » 2842780-11.x

I rerolled #168

rpayanm’s picture

Title: 2842780-11.x » Add a token for the site logo
neograph734’s picture

Status: Needs work » Needs review

Back to NR

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Going to mark it but left 1 comment in the MR for the committer.

neograph734’s picture

FYI, casting to string is a requirement for assertSame. See the link in failing test of #184.

anybody’s picture

@smustgrave see #189, perhaps that comment can be resolved?

Attached MR!4236 diff as static patch, if anyone needs it!

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -Needs maintainer +Needs change record

I am doing triage on the core RTBC queue.

I read the issue summary. There is a proposed resolution so reviewers know what to look for. However, the remaining tasks show another issue, is this issue supposed to be postponed on that or is a follow up needed?

This is adding tokens so there should be a Change record. This should include examples. I am adding the tag and setting to NW.

I then read the comments, mostly trying to find unanswered questions. Its that @Neograph734 did a very nice job keeping up with the feedback. It is hard to follow but I think everything has been responded to expect for two items.
1) There was concern about emails, #17. I am not sure if that was resolved. Or does this need documentation, including the CR, on how using these new tokens with mail will work.
2) Should be using a site-wide token, #173 - #180. In #176 @Berdir stated the proposed structure wouldn't work and there has been no other response from them on the subject. Has this truly been resolved? If that has been resolved it is worth adding a summary of that discussion in the Issue Summary so that it is clear for a committer.

I then read the MR, I did not do a code review. I spotted some things that need changing which I have commented on in the MR.

I am removing the 'Needs maintainer tag' because I think that intention is covered by 'Needs subsystem maintainer review' and it is not a defined special tag.
This is long issue in comments as well as time (7 years), thanks everyone for getting the bulk of the work done. Just a few more things to do.

atul4drupal’s picture

I tried to read through the thread to understand it, and as far I understood for #191 point 2:
@Berdir I believe is responding to the proposed suggestion for having seperate token type to which he disaggred, and that is something still not addressed as we see a new token type "site-logo" being introduced in the code.

Also @Berdir expressed for someone to verify if suggestions from #161 are implemented which I verifed have been incorporated and this was also verified in #180.

#191 point 1 (refering #17) this I think will relate to what approach we take with respect to the concern raised around introducing new token type, as in the current solution if we take off the new token type, #17 remain open.

It is a situation in hand, will spend some time on it however some direction around how to address #17 will be helpful, keeping in mind that people in general are not inclined towards introducing a new token type.

atul4drupal’s picture

StatusFileSize
new4.68 KB

Adding patch to update changes as suggested in #191.

Still have a few open TODO items on the issue:

1) Decide on an approach to address concern raised in #17 (possibly without adding new token type). If new token type needed then this need to be discussed and agreed upon before moving forward with this approach.

2) IS to be updated
(leaving this for someone who has more hold on this issue thread, will revisit to update IS if not updated in some time).

gouthamraon’s picture

StatusFileSize
new16.23 KB

#168 patch is not applying with the Drupal 10.1.5 version.
Issue with kernal test changes. Updated the changes and adding the new patch.

_utsavsharma’s picture

StatusFileSize
new15.76 KB
new15.95 KB

Fixed failures in #194.

anybody’s picture

Finally I gave up the hope that this will ever be finished by anyone (including me). So maybe we should better put our time into implementing a contrib solution?

Maybe in https://www.drupal.org/project/theme_tokens?
Seems there are enough people here to do that...

ramprassad made their first commit to this issue’s fork.

jeroent made their first commit to this issue’s fork.

jeroent’s picture

Status: Needs work » Needs review

I fixed the feedback in the MR.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new4.02 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

jeroent’s picture

Status: Needs work » Needs review

The tests were failing because the token hooks moved to a hook class.

Tests are now green again.

smustgrave’s picture

Status: Needs review » Needs work

There was already an MR for 11.x should continue there

jeroent’s picture

Status: Needs work » Needs review

Merged 11.x-dev back into the Merge request !4236

grevil changed the visibility of the branch 11.x to hidden.

grevil changed the visibility of the branch 11.x to hidden.

grevil’s picture

Current MR doesn't apply to latest 11.x any more. Rebasing is quite cumbersome, because the changes here conflict within themselves. Also there will be new conflicts for every new commit to 11.x now...

smustgrave’s picture

We actually don't have a token sub-maintainer so bumping to framework.

Can 1 MR be closed or hidden that's not for 11.x
4236 is 200+ commits back so probably will need a rebase at some point.
CR still appears to be needed

rbrissaud changed the visibility of the branch drupal-2842780-10.4.x-add-token-site-logo to hidden.

rbrissaud changed the visibility of the branch drupal-2842780-10.4.x-add-token-site-logo to hidden.

rbrissaud changed the visibility of the branch drupal-2842780-10.4.x-add-token-site-logo to hidden.

rbrissaud changed the visibility of the branch drupal-2842780-10.4.x-add-token-site-logo to hidden.

rbrissaud changed the visibility of the branch 2842780-11.x to hidden.

rbrissaud changed the visibility of the branch 2842780-11.x to hidden.

rbrissaud changed the visibility of the branch 2842780-11.x to hidden.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.66 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

jeroent changed the visibility of the branch 2842780-11.x to active.

jeroent’s picture

Status: Needs work » Needs review

Rebased the MR on 11.x.

grevil’s picture

Status: Needs review » Needs work
Issue tags: -Needs backport to D7, -#DCD19 +Needs issue summary update

RTBC! Works great and as expected for latest 11.x-dev.

Regarding #191:

I read the issue summary. There is a proposed resolution so reviewers know what to look for. However, the remaining tasks show another issue, is this issue supposed to be postponed on that or is a follow up needed?

No, the issue summary is fairly old. Both "default-" and "active-theme" works as expected.

There was concern about emails, #17. I am not sure if that was resolved. Or does this need documentation, including the CR, on how using these new tokens with mail will work.

If a user wants a specific theme logo or the default logo instead of the active theme logo, he can simply use the [site:logo:default-theme] or [site:logo:theme-my_theme] to specify the logo he wants.

Should be using a site-wide token, #173 - #180. In #176 @Berdir stated the proposed structure wouldn't work and there has been no other response from them on the subject. Has this truly been resolved? If that has been resolved it is worth adding a summary of that discussion in the Issue Summary so that it is clear for a committer.

The disussion was about adding new token types, but I think it was specifically about adding a "theme" type, as theoretically there are new token types added ("site-logo" and "site-logo-properties"), but they are mainly there to simply resolve to when using tokens such as [site:logo:default-theme] through "$token_service->findWithPrefix". So we don't really add new types but just new subtypes of "site".

TLDR: IMO, this is solved as well.

I'll create the change record and update the issue summary.

grevil’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update
grevil’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record

Created the change record here. That should be it! RTBC!

grevil’s picture

Status: Reviewed & tested by the community » Needs work

Tests fail now, maye because of removing the (string) type casting.

grevil’s picture

Status: Needs work » Needs review

Alright all done, back to needs review because of the new adjustments.

anybody’s picture

@quietone: @Grevil addressed your comments, could you see if they are fixed?
Would be great to get this one finished finally... :D

anybody’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new18.85 KB

Current status as static patch. Setting this RTBC for now as everything worked fine in my tests, but see my comment in #224 - would be great, if the framework manager could take a look and someone with permission could close the resolved GitLab comments. Thanks!

quietone’s picture

I had a go at updating credit, always a challenge on older issues with lots of comments.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

I think we need some usability input on the correct alt text here - or whether we should not have any at all. Note that the alt text was added due to my comment in #161 - but there was no subsequent discussion for what the alt text should be. I think in order to move this issue on we should remove the alt text here and file a follow-up to be reviewed by the usability team for what the alt should be and how it should work.

anybody’s picture

Issue tags: +Bug Smash Initiative

Hopefully this can finally get smashed? ;)

anybody’s picture

Issue tags: -Bug Smash Initiative

Sorry, this is not a bug. My mistake. Still waiting for reply from @alexpott, but would be super happy to get this DONE finally.
If it's fine to add this for Bug Smash Initiative please re-add. Sorry!

grevil’s picture

Status: Needs work » Reviewed & tested by the community

I agree with @anybody here. IMO, no alt text at all isn't good either.

We have a similar case in core, where the Drupal logo isn't perfect @core/modules/system/src/Plugin/Block/SystemBrandingBlock.php:

    $build['site_logo'] = [
      '#theme' => 'image',
      '#uri' => theme_get_setting('logo.url'),
      '#alt' => $this->t('Home'),
      '#access' => $this->configuration['use_site_logo'],
    ];

I'd say we leave it as is and create a follow-up issue, where we add the ability to change the alt text for both the Branding Block and this token.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

I think we should remove and open a follow-up. I think wrong and redundant alt text is more harmful than no alt text to humans. Yes we'll probably do pass tests on checkers which just test if alt text exists rather than the quality but we should care about humans more than automated checkers.

alexpott’s picture

FWIW I should have asked for a follow-up to discuss alt text back in 2022 #161... as this debate in this issue is all my fault. Sorry.

grevil’s picture

Status: Needs work » Needs review

I removed the alt text, replaced the deprecated "theme_get_setting" call and rebased the issue fork.

grevil’s picture

anybody’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#3554559: Add alt text configuration for the site logo (and [site:logo] token)

Thank you very much for finishing this @grevil and creating the follow-up! I left a comment there, but that's out of scope here.

Back to RTBC then. @alexpott should we remove the Needs framework manager review tag? Is all fine then?

anybody’s picture

PS: Regarding theme_get_setting() deprecation (https://www.drupal.org/node/3035289 - #3035288: Deprecate theme_get_setting()) please note that the minimum core version for this fix will be the same as over there - or we'll have to revert that for the cherry-pick!

grevil’s picture

Status: Reviewed & tested by the community » Needs work

Tests fail.

jeroent’s picture

Status: Needs work » Needs review

Fixed the failing tests.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @jeroent!

amanire’s picture

Glad to see this issue moving forward. Another good use case for this token is Schema.org Metatag.

anybody’s picture

@quietone @alexpott this needs a reroll again. Do we have a chance to finally review and eventually merge afterwards for finishing? :)

grevil’s picture

StatusFileSize
new19.24 KB

New rebased patch attached.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new776 bytes

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

anybody’s picture

Status: Needs work » Reviewed & tested by the community

Rebased. Everything green again!

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new776 bytes

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

anybody’s picture

@nod_ everything is green, so I think the testbot sets it to NW because it has "Needs framework manager review"?
Will this be reviewed by the framework manager automatically?

The issue is 9Y old and has much activity so I think we should be happy if it can be resolved finally?

smustgrave’s picture

Status: Needs work » Reviewed & tested by the community

Did not review. HEAD was broken so it tricked the bot

godotislate made their first commit to this issue’s fork.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new548 bytes

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

anybody’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: +no-needs-review-bot
larowlan’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs framework manager review +Needs product manager review

From a framework manager point of view, I don't think this fits the 80% use case. Additionally it can be achieved in contrib - the MR shows that the existing token APIs/hooks don't prevent this from living in a contrib module.

I realise a lot of effort has gone into this, but I don't think in our new Product (Drupal CMS) vs Framework (Drupal Core) world that this is a framework feature. I'll poll other committers including product managers - but from my point of view I think we should encourage this to live in contrib.

neograph734’s picture

@larowlan, My personal argument is that all other elements from the system branding block (site name and slogan) are available as site tokens provided by core.
Those are defined in a different config, but they are displayed as one.

Also modules such as Metadata might benefit from this patch by having the site logo easily accessible(?).

anybody’s picture

I have to agree with @Neograph734 (#253) while this is definitely worth the discussion, I also think the benefit is large enough, a lot of work went into this and we for example need this in nearly all projects (everywhere Metatag module is used - which is quite a lot).
So I'd vote to add this in core.

P.S.: I think the fact that so many different users are active here is also very good evidence.

darvanen’s picture

@Anybody may I ask how many of those sites don't have the token module installed?