הגדר אימוג'י מותאם אישית

:bookmark: This guide explains how to configure custom emojis on your Discourse site.

:person_raising_hand: Required user level: Administrator

Configuring custom emoji

Want to change emoji for your Discourse site? Let’s take a look at how to configure custom emoji for your Discourse site, including selecting emoji sets, uploading new emoji, and adjusting emoji sizes.

Selecting an emoji set

Discourse comes with seven different emoji sets:

  • Apple/International style
  • Google style
  • Twitter style
  • Emoji One style
  • Win10 style
  • Google Classic
  • Facebook Messenger

You can select an emoji set at /admin/config/emoji/settings?filter=emoji%20set along with other emoji-related settings.

Adding custom emoji

To add custom emoji:

  1. Navigate to: Discourse Admin - Config - Emoji at /admin/config/emoji
  2. You can:
    • Enter a name and click Add emoji to upload a photo as an emoji
    • Drag and drop up to 10 files into the Name field to bulk upload; filenames will be used as emoji names.



Resizing custom emoji

By default, all emoji are resized via CSS to 20x20, but this can be overridden with custom CSS. To maintain the correct aspect ratio and native size in posts, add the following CSS:

/* Make emoji normal size (don't force square) */
div.topic-post img.emoji[src*="uploads"], 
div.d-editor-preview img.emoji[src*="uploads"], 
div.emoji-modal img.emoji[src*="uploads"], 
div.d-editor-textarea-wrapper img.emoji[src*="uploads"], 
div.title-wrapper img.emoji[src*="uploads"], 
td.main-link img.emoji[src*="uploads"] {
    width: auto;
    height: auto;
}

To customize a specific emoji’s size, use:

img.emoji[title=":youremoji:"] { 
    height: XXpx; 
    width: YYpx; 
}

For resizing emoji in chat messages and user status in chats:

div.chat-message-text img.emoji[src*="uploads"], 
span.user-status-message img.emoji[src*="uploads"] {
    width: auto;
    height: auto;
}

Last edited by @martin 2025-01-23T05:07:38Z

Check documentPerform check on document:
33 לייקים

I noticed that the custom emojis/smileys show 20x20 in chat messages and in the user status in chats. I solved it that way:

div.chat-message-text img.emoji[src*="uploads"] { /* Chat messages */
    width: auto;
    height: auto;
}

span.user-status-message img.emoji[src*="uploads"] { /* User status in chat */
    width: auto;
    height: auto;
}

Would you do it that way, too? If yes, it might be useful to add it to this wiki post above. If not, I am happy to optimize my CSS code. :wink:

3 לייקים

I customized new Emoji, but I can t it find among another Emojis.

לייק 1

Have you scrolled all the way down in the emoji picker? That’s where your custom emoji groups live.

2 לייקים

Those have changed:

ניסיתי כמה אפשרויות שונות להעלאה המונית של אימוג’י מותאם אישית, אבל לא הצלחתי למצוא פתרון אז אני שואל כאן מה האפשרות הטובה ביותר לעתיד.

יש לי אוסף קטן של אימוג’י מותאם אישית שאני אוהב להעלות לכל הדיסקורסים שלי. חלקם הם אייקוני FontAwesome, שאני אוהב שיהיו זמינים כ-:icon-name: בפוסטים של מלחין כדי שאוכל להסביר אייקוני ממשק משתמש של Discourse למשתמשים. אחרים הם סתם בשביל הכיף כמו דגל יורקשייר. יש לי אותם בתיקיות (ואפשר גם שיהיו באינטרנט במאגר GitHub אני מניח).

הייתי רוצה להיות מסוגל להעלות את כל התיקיות האלה, בבת אחת, לממשק המשתמש של אימוג’י מותאם אישית. כרגע המגבלה על העלאות מכבדת את ההגדרה של simultaneous_uploads (מספר מקסימלי של קבצים שניתן לגרור ולשחרר במלחין) בהגדרות האתר, אשר מוגבלת לערך תקרה של 20 (שגיאה: “simultaneous_uploads: הערך חייב להיות בין 0 ל-20.” אם תנסה להגדיל אותו יותר, אפילו באופן זמני)

חקרתי בעניין את הגדרת האימוג’י האחרת external-emoji-url, אשר מאפשרת להגדיר URL עבור סט אימוג’י חיצוני, אבל לצערי זה מחליף את כל האימוג’י ה’סטנדרטיים’, שאני לא רוצה לאבד.

כל מה שאני באמת צריך זה שהעלאת תיקיות של אימוג’י מותאם אישית תעבוד כמו שזה עובד כרגע עבור אימוג’י מותאם אישית בודד. לחלופין, אם לא הייתה מגבלה על מספר ההעלאות המותרות (אולי משימת ההעלאה יכולה להישלח ל-SideKiq כדי שתתבצע באופן אסינכרוני, ולשלוח PM למנהלים כשהיא תסתיים, כמו בהזמנות המוניות)

בדקתי את השימוש ב-Discourse REST API עבור זה, אבל אימוג’י מותאם אישית לא נחשף דרך REST API. העלאות נחשפות ב-API, וזה עבד לי, אבל גם אם משתמשים בסוג custom_emoji להעלאה, זה לא מופיע ברשימה.

אני רק תוהה מה הקהילה חושבת שתהיה הדרך הטובה ביותר להתקדם:

  • משימת Rake שמבצעת אוטומציה של יצירת אימוג’י מותאם אישית בכמות גדולה?
  • לעשות את זה במסוף Rails?
  • לשנות את מגבלות ההעלאה של ממשק המשתמש למנהל כדי לאפשר כמה מאות העלאות בבת אחת?
  • להוסיף ‘העלאת תיקייה’ לממשק המשתמש למנהל?
  • להפוך אימוג’י מותאם אישית למשהו שאני יכול לפרוס כרכיב ערכת נושא שאני יכול להוסיף מכתובת URL של GitHub? (אני אוהב את הפשטות של זה)
  • לאפשר כתובות URL מרובות של אימוג’י חיצוניים כדי שאוכל לקבל סט אימוג’י וגם את האימוג’י המותאם אישית שלי (אולי יוגש ממאגר דפי GitHub)
  • לפרוץ יחד מאגר יחיד של ‘אימוג’י ואימוג’י מותאם אישית’ שאני יכול לפנות אליו באמצעות URL?

או - האם יש דרך אחרת לגרום לכל אייקוני FontAwesome ש-Discourse משתמש בהם בממשק המשתמש שלו להיות זמינים במלחין באמצעות תחביר :icon-name:? באמת שרוב מה שאני רוצה לעשות קשור לזה. הגדרת אתר המאפשרת לאייקוני ממשק משתמש להיות זמינים במלחין תביא אותי ל-90% ממה שאני צריך.

2 לייקים

I have used the Discourse Icon theme component for a similar use case, if that’s any help?

Example from the topic:

This is the [wrap=icon id=far-square][/wrap] icon and the [wrap=icon id=pencil][/wrap] icon.

This is the icon and the icon.

3 לייקים

תודה @JammyDodger זה מועיל ובהחלט אופציה שאשקול, למרות שה-UX של תחביר [wrap=icon id=icon-name][/wrap] לא נעים כמו :icon-name:.

חיסרון בגישת Discourse Icon הוא שאני צריך להוסיף ידנית רשימה של כל הסמלים שאני רוצה להשתמש בהם בהגדרת האתר svg icon subset. אבל לפחות אפשר לעשות את זה בבת אחת על ידי העתקה והדבקה מרשימה בקובץ טקסט.

לייק 1

From your description, I wouldn’t expect you to have to add that much. The setting is to add more icons. All icons that are used in the forum are already available.

לייק 1

Where are they available? I welcome it, if they are. But I can’t seem to access them with the :icon-name: type syntax.

I just want to easily be able to tell people, for example, that to add a timezone-aware datetime to a post they use the :calendar-days: button in the Composer toolbar. But when I search the included emoji/icons the nearest thing I can get is :spiral_calendar:.

They work with the wrap syntax and Discourse icon without adding them to svg icon subset.

The answer referred to your comment that it is a disadvantage that you have to add all the icons.


Maybe it would work to use watched-words to replace :calendar-days: with [wrap=icon id=calendar-days][/wrap] :thinking:

4 לייקים

Ah OK, thanks and apologies for my misunderstanding. This is awesome. So I can use anywhere using wrap syntax! Every day is a Discourse school day!

The only missing part is the ability to easily search for the Discourse name of the icon I need, but I guess I can always use the browser inspector to find the d-icon- name and adjust accordingly. Or the FontAwesome website.

Thanks @Moin

2 לייקים

Something changed since I last updated Discourse (some days ago).

Instead of

image

it now looks

image

When I check CSS there is a element.style (so a style inside HTML for this emoji) aspect-ratio: 20 / 20; and if I disable it, the emoji looks like it should.

What to do?

(Btw, “Choker” doesn’t have anything to say. It is about scuba diving and not other things :stuck_out_tongue: and just there to see the size of the text in the post.)

You could adding this css lines in your themes

.emoji-custom {
    aspect-ratio: unset !important;
}

It will override the aspect-ratio: 20/20

2 לייקים

Great thank you, that did work! :+1:

May I ask:

What is the purpose of setting the aspect ratio in the latest release?

And why isn’t this CSS, also the code mentioned above, not included in core Discourse? Is this breaking something else or are too less people using custom emojis/smileys?

2 לייקים

I honestly don’t know, I guess it’s related to this discussion

2 לייקים