mirror of
https://github.com/flarum/framework.git
synced 2025-04-25 14:14:03 +08:00
Add lazy loading attribute to twemoji rendered images & autocomplete (#31)
This commit is contained in:
parent
1b08d47f6e
commit
97c89bcc42
@ -77,7 +77,7 @@ export default function addComposerAutocomplete() {
|
||||
onmouseenter={function() {
|
||||
dropdown.setIndex($(this).parent().index() - 1);
|
||||
}}>
|
||||
<img alt={emoji} class="emoji" draggable="false" src={`${cdn}72x72/${code}.png`}/>
|
||||
<img alt={emoji} class="emoji" draggable="false" loading="lazy" src={`${cdn}72x72/${code}.png`}/>
|
||||
{name}
|
||||
</button>
|
||||
);
|
||||
|
@ -7,12 +7,19 @@ import Post from 'flarum/models/Post';
|
||||
|
||||
import base from './cdn';
|
||||
|
||||
const options = {
|
||||
base,
|
||||
attributes: () => ({
|
||||
loading: 'lazy',
|
||||
}),
|
||||
};
|
||||
|
||||
export default function renderEmoji() {
|
||||
override(Post.prototype, 'contentHtml', function(original) {
|
||||
const contentHtml = original();
|
||||
|
||||
if (this.oldContentHtml !== contentHtml) {
|
||||
this.emojifiedContentHtml = twemoji.parse(contentHtml, { base });
|
||||
this.emojifiedContentHtml = twemoji.parse(contentHtml, options);
|
||||
this.oldContentHtml = contentHtml;
|
||||
}
|
||||
|
||||
@ -22,6 +29,6 @@ export default function renderEmoji() {
|
||||
override(s9e.TextFormatter, 'preview', (original, text, element) => {
|
||||
original(text, element);
|
||||
|
||||
twemoji.parse(element, { base });
|
||||
twemoji.parse(element, options);
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user