4

I have uploaded a logo in the General Settings, which I understand changes the logo on the login page.

I was wondering if there was anyway to display this same logo in the site's template?

I know I can achieve this by hard-coding the same URL (but I presume if the logo is changed, this URL will change also.) My other solution is to add a field to a global set but that requires changing the logo in 2 places.

If this isn't possible, how can I retrieve the URL in a plugin? (I have a plugin with a few template helper methods.)

Thanks

5

To fetch the logo:

{{ craft.rebrand.logo.url }}

To check if a logo is uploaded:

{% if craft.rebrand.isLogoUploaded %}
| improve this answer | |
  • That's great, thanks. I decided to go with using an asset in the end, purely because I can then add alt-text and title using the control panel (and additional fields on the asset.) – Andy H Jan 12 '15 at 11:15
  • Also I know this is only a feature for Client and above, but it would be useful if this was documented in the templating reference (buildwithcraft.com/docs/templating). I didn't see it anywhere so forgive me if it already is! – Andy H Jan 12 '15 at 11:15
  • I haven't seen it mentioned anywhere. Found it be having a look the template login.html. By the way, you should mark this as accepted answer. – Fred Carlsen Jan 12 '15 at 12:51
3

For version 3.x.x.

Check and get rebrand logo:

{% if craft.rebrand.isLogoUploaded() %}
    <img width="{{ craft.rebrand.getLogo().size[0] }}" height="{{ craft.rebrand.getLogo().size[1] }}" src="{{ craft.rebrand.getLogo().url }}">
{% else %}
    Not set.
{% endif %}

Check and get rebrand icon:

{% if craft.rebrand.isIconUploaded() %}
    <img width="{{ craft.rebrand.getIcon().size[0] }}" height="{{ craft.rebrand.getIcon().size[1] }}" src="{{ craft.rebrand.getIcon().url }}">
{% else %}
    Not set.
{% endif %}

Documentation for twig rebrand variable is here: https://docs.craftcms.com/api/v3/craft-web-twig-variables-rebrand.html#public-methods

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.