Fix issue for custom image badges urls (#5814)

This commit is contained in:
Alexis Duran 2018-05-11 04:29:24 -04:00 committed by Régis Hanol
parent 4f508b2358
commit 1404294a12
3 changed files with 12 additions and 5 deletions

View File

@ -1,7 +1,14 @@
import { htmlHelper } from 'discourse-common/lib/helpers';
import { iconHTML } from 'discourse-common/lib/icon-library';
export default htmlHelper(function(str) {
if (Ember.isEmpty(str)) { return ""; }
return (str.indexOf('fa-') === 0) ? iconHTML(str.replace('fa-', '')) : `<img src='${str}'>`;
export default htmlHelper(function({ icon, image }) {
if (!Ember.isEmpty(image)) {
return `<img src='${image}'>`;
}
if (Ember.isEmpty(icon) || icon.indexOf('fa-') !== 0) {
return '';
}
return iconHTML(icon.replace('fa-', ''));
});

View File

@ -1,3 +1,3 @@
{{icon-or-image badge.icon}}
{{icon-or-image badge}}
<span class="badge-display-name">{{badge.name}}</span>
{{yield}}

View File

@ -7,7 +7,7 @@
<div class='badge-contents'>
<a href={{url}} class="badge-link">
<div class='badge-icon {{badge.badgeTypeClassName}}'>
{{icon-or-image badge.icon}}
{{icon-or-image badge}}
</div>
<div class='badge-info'>
<div class='badge-info-item'>