Is it possible to change the icon for staff notices?

Is it possible to change the icon used on Staff Notices, either through css or a setting that I just haven’t found? Preferably we’d like to swap it out for a custom picture rather than a FA icon.

1 Like

We do not have a setting for that and I think doing it in CSS only is difficult, but you can create a theme component to replace it.

In CSS, you will hide the old icon:

.post-notice {
  .d-icon-user-shield {
    display: none;
  }
}

In JavaScript (you put this in <head> of the theme component), you will decorate the notice and add the new icon:

<script type="text/discourse-plugin" version="0.8">
  const { iconNode } = require("discourse-common/lib/icon-library");
  api.decorateWidget('post-notice:before', helper => {
    return iconNode('heart');
  });
</script>

… or if you want to replace with an image…:

<script type="text/discourse-plugin" version="0.8">
  api.decorateWidget('post-notice:before', helper => {
    return helper.h('img', {
      src: 'https://www.discourse.org/a/img/home-spot-1.png',
      style: 'margin-right: 0.65em',
      height: 30,
      width: 30
    });
  });
</script>

With themes and theme components, the sky is the limit. If you want to learn more, we have a resource for that:

12 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.