mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -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:
parent
87c01c131b
commit
a16077a8e3
2 changed files with 20 additions and 2 deletions
|
@ -6,6 +6,10 @@ module.exports = {
|
||||||
// let version = opts.options.version;
|
// let version = opts.options.version;
|
||||||
let dom = opts.env.dom;
|
let dom = opts.env.dom;
|
||||||
|
|
||||||
|
if (!payload.src) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
let figure = dom.createElement('figure');
|
let figure = dom.createElement('figure');
|
||||||
figure.setAttribute('class', 'kg-image-card');
|
figure.setAttribute('class', 'kg-image-card');
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ const SimpleDom = require('simple-dom');
|
||||||
const serializer = new SimpleDom.HTMLSerializer(SimpleDom.voidMap);
|
const serializer = new SimpleDom.HTMLSerializer(SimpleDom.voidMap);
|
||||||
|
|
||||||
describe('Image card', function () {
|
describe('Image card', function () {
|
||||||
it('generates an image', function () {
|
it('renders an image', function () {
|
||||||
let opts = {
|
let opts = {
|
||||||
env: {
|
env: {
|
||||||
dom: new SimpleDom.Document()
|
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>');
|
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 = {
|
let opts = {
|
||||||
env: {
|
env: {
|
||||||
dom: new SimpleDom.Document()
|
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>');
|
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 () {
|
describe('sizes', function () {
|
||||||
it('standard', function () {
|
it('standard', function () {
|
||||||
let opts = {
|
let opts = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue