This would be a useful feature in emails and also in #821484: Add token support to the holding page.

CommentFileSizeAuthor
#20 token-logo.jpg150.93 KBalexverb
#19 token.site-logo.823780-19.patch1.83 KBalexverb
#15 token.site-logo.823780-15.patch1.71 KBAdamPS
PASSED: [[SimpleTest]]: [MySQL] 347 pass(es). View
#10 823780-10-logo-token-module.patch1.67 KByvesvanlaer
PASSED: [[SimpleTest]]: [MySQL] 347 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

muximus’s picture

would be nice

bensnyder’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Priority: Normal » Major

+1 for a logo token!

Thanks :)

Dave Reid’s picture

Priority: Major » Normal
docans’s picture

I also agree very much

bojanz’s picture

Commerce Kickstart v2 does this:

/**
 * Implements hook_tokens().
 */
function commerce_kickstart_order_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  foreach ($tokens as $name => $original) {
    if ($name == 'site-logo') {
      $replacements[$original] = theme('image', array('path' => theme_get_setting('logo')));
    }
  }

  return $replacements;
}

might help someone with rolling the patch, or solving an immediate need.

lsolesen’s picture

Remember

/**
 * Implements hook_token_info().
 */
function commerce_kickstart_order_token_info() {
  $info['tokens']['commerce-order']['site-logo'] = array(
    'name' => t('Site logo'),
    'description' => t('The logo of the site.'),
  );

  return $info;
}
DamienMcKenna’s picture

Issue summary: View changes

Closed a duplicate: #2059531: Add a token to output the site's logo

BTW Ubercart (yes!) has a token for this already.

RaulMuroc’s picture

This is really a nice feature. In my sparece time will try to fix it :)

DamienMcKenna’s picture

@RaulMuroc: Nobody has put the time into building a patch for it, that's why it hasn't been fixed yet.

If you had an hour-or-two to spare you could build a patch and upload it for us to review? *nudge* *nudge* :-)

yvesvanlaer’s picture

Status: Active » Needs review
FileSize
1.67 KB
PASSED: [[SimpleTest]]: [MySQL] 347 pass(es). View

Hello

I created a small module which add a logo token. Really weird that it wasn't just there.

DamienMcKenna’s picture

Status: Needs review » Needs work
RaulMuroc’s picture

Perhaps is better to have it as a module

https://www.drupal.org/sandbox/raulmuroc/2335571

kaare’s picture

No, this should not be hidden away in a tiny module. It's a fundamental part of the [site:] namespace and belongs in the token module. I was flabbergasted when I did not find it in the token browser while adding Meta tags to my site :-)

AdamPS’s picture

Is there a consensus on exactly what the token should do?

  • The commerce and ubercart code seem to return themed HTML for displaying the image.
  • The modules seem to return the path to the logo.

Potentially both are useful. New code here should be compatible with existing code. So site:logo could output the themed image and site:logo-url could return the URL (with options for site:logo-url:path etc).

I agree with @kaare this is better in the token module than a separate one or a sub-module. Hopefully one of us will find time to make a patch soon.

AdamPS’s picture

Status: Needs work » Needs review
FileSize
1.71 KB
PASSED: [[SimpleTest]]: [MySQL] 347 pass(es). View

OK, I give in:-) Here is a patch. I think it will work on both dev and the stable release.

It is based on Ubercart which implemented site:logo (commerce uses a module-specific name) and also handles the logo missing case.

I have added site:logo-url (with chaining). This is useful for example when building a URL that links back to the logo (e.g. a Pinterest share button http://pinterest.com/pin/create/button/?url=[site:url]&media=[site:logo-...)

kopeboy’s picture

Please can we have this!?

I was so surprised [site:logo] didn't exist already :(

chegor’s picture

+1 for commiting this.

AdamPS’s picture

@chegor @kopeboy Thanks for the vote in favour. Next step is for someone to set status to "reviewed and tested by the community". If you have reviewed and/or tested, please update the status, thanks.

alexverb’s picture

I'm going to test this patch right away. But since #15 gave me whitespace warnings I've removed those in this patch first.

alexverb’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
150.93 KB

The patch works for me. I've done the following steps:
https://simplytest.me/project/token/7.x-1.x?patch[]=https://www.drupal.o...

  1. Enable advanced_text_formatter module
  2. Check " Show available tokens in field's description" on body field of article
  3. Change display format of field to Advanced Text and check "Token replace", save Display.
  4. Add content > Article > Put in logo tokens > Select full HTML > Save

The following is the result:

Token logo

catFighter’s picture

#19 works very good. In Drupal Commer from #5 i #6 doesn't work becasue generate array notice and logo doesn't show. But #19 will be helpfull!!

nickonom’s picture

#19 also worked for me. There are two new tokens after applying the patch: [site:logo] and [site:logo-url]

RTBC

maxplus’s picture

Great,
#19 is working for me, using it in a Message type

kopeboy’s picture

Please include this!

Neograph734’s picture

Since I figured all site:* tokens are defined in Drupal core (system.tokens.inc), I figured it made more sense to implement this feature in Drupal core.

So I have just proposed this to Drupal 8: #2842780: Add a token for the site logo and added the needs backport flag to get it into D7. IMHO that would be a better place for it.

(I am not associated to this module whatsoever, so one of the maintainers may prove me wrong :) )

delacosta456’s picture

Hi .. #19 is Working for me to0 on PHP 5.5 + Mysql 5.5 D7 ....
Also worked in Page Manager and Panel

thanks

vasike’s picture

i also confirm that #19 patch works

Neograph734’s picture

Status: Reviewed & tested by the community » Needs work
Related issues: +#2842780: Add a token for the site logo

It might not...

As explained in #25, I have performed a direct port of this patch for Drupal 8. The feedback alexpott gave me there was that there was not enough control over what logo will be selected. (In cases where you configure the Bartik logo, but send a mail from the admin interface, etc.) See #2842780-17: Add a token for the site logo.

The same applies to this patch, it just takes the logo from the current theme, which might cause unexpected behavior.

UPDATE

I have attempted to overcome the issue by providing a theme parameter ([site:logo:?], [site:logo-url:?]) to fetch a logo for a specific theme and having [site:logo] and [site:logo-url] always return the logo of the default theme.