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.
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:
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
Ya he probado esto; el primer fragmento de código JS necesitaba una pequeña actualización.
Esto ahora necesita ir en la pestaña JS de un Componente de Tema (o Tema) en su lugar:
import { apiInitializer } from "discourse/lib/api";
import { iconNode } from "discourse-common/lib/icon-library";
export default apiInitializer("0.11.1", (api) => {
api.decorateWidget("post-notice:before", () => {
return iconNode("heart");
});
});
No miré cómo usar una imagen en su lugar, lo siento.
Después de agregarlo a mi tema, vi una advertencia debido a Upcoming post stream changes - How to prepare themes and plugins. Así que me preocupa que pronto se necesite otra actualización.
Lo intenté porque tenía curiosidad si solo afectaba las notas del personal o también las notas de usuarios nuevos y recurrentes, ya que todos son avisos de publicaciones.
Afecta a todos los avisos de publicaciones, mientras que el CSS anterior solo oculta el escudo. Así que terminas con dos íconos en los avisos de usuarios nuevos y recurrentes.
¡Eso es un poco insatisfactorio entonces!
En mi prisa por publicar eso, olvidé que no había eliminado api.decorateWidget. Debo haber descartado el error en mi sitio sin darme cuenta.
Estoy seguro de que el CSS podría ser mejor dirigido, pero acabo de descubrir Quote Callouts - creo que esto servirá mejor a mi caso de uso de todos modos.


