Skip to content

Commit ee04731

Browse files
silverwindzeripathtechknowlogick
authored
Fix emoji replacements, make emoji images consistent (#12567)
- Fix emoji not being replaced in issue title change text - Make the image attributes consistent, add alt, remove align Co-authored-by: zeripath <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 26bf4c5 commit ee04731

File tree

5 files changed

+5
-4
lines changed

5 files changed

+5
-4
lines changed

modules/markup/html.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ func createCustomEmoji(alias, class string) *html.Node {
481481
Attr: []html.Attribute{},
482482
}
483483
if class != "" {
484+
img.Attr = append(img.Attr, html.Attribute{Key: "alt", Val: fmt.Sprintf(`:%s:`, alias)})
484485
img.Attr = append(img.Attr, html.Attribute{Key: "src", Val: fmt.Sprintf(`%s/img/emoji/%s.png`, setting.StaticURLPrefix, alias)})
485486
}
486487

modules/markup/html_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ func TestRender_emoji(t *testing.T) {
255255
//Text that should be turned into or recognized as emoji
256256
test(
257257
":gitea:",
258-
`<p><span class="emoji" aria-label="gitea"><img src="`+setting.StaticURLPrefix+`/img/emoji/gitea.png"/></span></p>`)
258+
`<p><span class="emoji" aria-label="gitea"><img alt=":gitea:" src="`+setting.StaticURLPrefix+`/img/emoji/gitea.png"/></span></p>`)
259259

260260
test(
261261
"Some text with 😄 in the middle",

modules/templates/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ func ReactionToEmoji(reaction string) template.HTML {
607607
if val != nil {
608608
return template.HTML(val.Emoji)
609609
}
610-
return template.HTML(fmt.Sprintf(`<img src=%s/img/emoji/%s.png></img>`, setting.StaticURLPrefix, reaction))
610+
return template.HTML(fmt.Sprintf(`<img alt=":%s:" src="%s/img/emoji/%s.png"></img>`, reaction, setting.StaticURLPrefix, reaction))
611611
}
612612

613613
// RenderNote renders the contents of a git-notes file as a commit message.

templates/repo/issue/view_content/comments.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
</a>
219219
<span class="text grey">
220220
<a class="author" href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a>
221-
{{$.i18n.Tr "repo.issues.change_title_at" (.OldTitle|Escape) (.NewTitle|Escape) $createdStr | Safe}}
221+
{{$.i18n.Tr "repo.issues.change_title_at" (.OldTitle|RenderEmoji) (.NewTitle|RenderEmoji) $createdStr | Safe}}
222222
</span>
223223
</div>
224224
{{else if eq .Type 11}}

web_src/js/features/emoji.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ for (const key of emojiKeys) {
2424
export function emojiHTML(name) {
2525
let inner;
2626
if (name === 'gitea') {
27-
inner = `<img class="emoji" alt=":${name}:" src="${StaticUrlPrefix}/img/emoji/gitea.png" align="absmiddle">`;
27+
inner = `<img alt=":${name}:" src="${StaticUrlPrefix}/img/emoji/gitea.png">`;
2828
} else {
2929
inner = emojiString(name);
3030
}

0 commit comments

Comments
 (0)