0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Koenig - Do not render image cards with no src on the front-end

refs https://github.com/TryGhost/Ghost/issues/9623
- blank images may be used in the editor as placeholders, don't render them on the front-end
This commit is contained in:
Kevin Ansfield 2018-06-14 14:57:09 +01:00
parent 87c01c131b
commit a16077a8e3
2 changed files with 20 additions and 2 deletions

View file

@ -6,6 +6,10 @@ module.exports = {
// let version = opts.options.version;
let dom = opts.env.dom;
if (!payload.src) {
return '';
}
let figure = dom.createElement('figure');
figure.setAttribute('class', 'kg-image-card');

View file

@ -4,7 +4,7 @@ const SimpleDom = require('simple-dom');
const serializer = new SimpleDom.HTMLSerializer(SimpleDom.voidMap);
describe('Image card', function () {
it('generates an image', function () {
it('renders an image', function () {
let opts = {
env: {
dom: new SimpleDom.Document()
@ -17,7 +17,7 @@ describe('Image card', function () {
serializer.serialize(card.render(opts)).should.eql('<figure class="kg-image-card"><img src="https://www.ghost.org/image.png" class="kg-image"></figure>');
});
it('generates an image with caption', function () {
it('renders an image with caption', function () {
let opts = {
env: {
dom: new SimpleDom.Document()
@ -31,6 +31,20 @@ describe('Image card', function () {
serializer.serialize(card.render(opts)).should.eql('<figure class="kg-image-card"><img src="https://www.ghost.org/image.png" class="kg-image"><figcaption>Test caption</figcaption></figure>');
});
it('renders nothing with no src', function () {
let opts = {
env: {
dom: new SimpleDom.Document()
},
payload: {
src: '',
caption: 'Test caption'
}
};
serializer.serialize(card.render(opts)).should.eql('');
});
describe('sizes', function () {
it('standard', function () {
let opts = {