mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
🐛 Koenig - Fixed missing alt
text on images
refs https://github.com/TryGhost/Ghost/issues/9724 - render `alt` attribute if the image card payload has an `alt` property
This commit is contained in:
parent
a1723a687c
commit
5b80ec44ab
2 changed files with 17 additions and 0 deletions
|
@ -20,6 +20,9 @@ module.exports = {
|
||||||
let img = dom.createElement('img');
|
let img = dom.createElement('img');
|
||||||
img.setAttribute('src', payload.src);
|
img.setAttribute('src', payload.src);
|
||||||
img.setAttribute('class', 'kg-image');
|
img.setAttribute('class', 'kg-image');
|
||||||
|
if (payload.alt) {
|
||||||
|
img.setAttribute('alt', payload.alt);
|
||||||
|
}
|
||||||
|
|
||||||
figure.appendChild(img);
|
figure.appendChild(img);
|
||||||
|
|
||||||
|
|
|
@ -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 an image with alt text', function () {
|
||||||
|
let opts = {
|
||||||
|
env: {
|
||||||
|
dom: new SimpleDom.Document()
|
||||||
|
},
|
||||||
|
payload: {
|
||||||
|
src: 'https://www.ghost.org/image.png',
|
||||||
|
alt: 'example image'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
serializer.serialize(card.render(opts)).should.eql('<figure class="kg-image-card"><img src="https://www.ghost.org/image.png" class="kg-image" alt="example image"></figure>');
|
||||||
|
});
|
||||||
|
|
||||||
it('renders nothing with no src', function () {
|
it('renders nothing with no src', function () {
|
||||||
let opts = {
|
let opts = {
|
||||||
env: {
|
env: {
|
||||||
|
|
Loading…
Reference in a new issue