Reputation: 97
How to change Wagtail Userbar Icon? I want to make it more personalize but I don't know how since I am new in web development.
Upvotes: 4
Views: 2279
Reputation: 1556
For some reason the accepted answer stopped working for me in the latest version of Wagtail. Rather than figure out why, I found a simpler solution:
Create wagtailadmin/userbar/base.html
:
{% extends "wagtailadmin/userbar/base.html" %}
{% load wagtailadmin_tags i18n %}
{% block branding_logo %}
<div style="display: none">
<svg>
<defs>
<!-- Replace 'wagtail.svg' with whatever you want from the icons directory, e.g. 'cogs.svg' -->
{% include "wagtailadmin/icons/cogs.svg" %}
{% include "wagtailadmin/icons/folder-open-inverse.svg" %}
{% include "wagtailadmin/icons/edit.svg" %}
{% include "wagtailadmin/icons/plus.svg" %}
{% include "wagtailadmin/icons/tick.svg" %}
{% include "wagtailadmin/icons/cross.svg" %}
</defs>
</svg>
</div>
<!-- Update the icon name -->
{% icon name="cogs" class_name="wagtail-userbar-icon" %}
{% endblock %}
Upvotes: 3
Reputation: 42
You can also modify wagtail's icon font. Then you don't have to touch any of the code.
The font file is at https://github.com/wagtail/wagtail/blob/8e0b2f6d1da6c18ad1aaaa8366f02e6c8cf76027/wagtail/admin/static_src/wagtailadmin/fonts/wagtail-icomoon.json
I used a slightly modified version of the instructions at https://github.com/wagtail/wagtail/wiki/Adding-new-icon
as long as your app comes before wagtail.admin in INSTALLED_APPS it will use your modified font instead modified icon
Upvotes: 2
Reputation: 1446
You can also insert a FontAwesome icon instead, just create the HTML page wagtailadmin/userbar/base.html in one of your Django app templates folders. This will override the html provided by Wagtail.
Then in the template delete the call to the wagtail-icon CSS class, which inserts the Wagtail logo, and insert your icon, in this case a fontawesome pencil icon ...
<div class="wagtail-userbar-trigger" data-wagtail-userbar-trigger>
<i class="fas fa-pencil-alt fa-2x"></i>
<span class="wagtail-userbar-help-text">
{% trans 'My personal admin interface' %}
</span>
</div>
Here is how to adjust size etc of the Fontawesome image, in this case fa-2x doubles the size of the pencil.
Wagtails built-in edit icon can be used by editing the div class like so ...
<div class="wagtail-userbar-trigger wagtail-icon wagtail-icon-edit" data-wagtail-userbar-trigger>
The FontAwesome method provides more options though.
Note: As mentioned this creates a maintainability issue, however IMO usability would be increased by this change, as most users do not understand what Wagtail CMS is, or what clicking a bird might symbolise.
Upvotes: 2