mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Koenig - Render image title
attribute if present
refs https://github.com/TryGhost/Ghost/issues/9724 - `<img>` elements can have both `alt ` and `title` attributes, ensure we render both of them
This commit is contained in:
parent
cfd9ff3993
commit
66fb0955a4
2 changed files with 17 additions and 0 deletions
|
@ -23,6 +23,9 @@ module.exports = {
|
|||
if (payload.alt) {
|
||||
img.setAttribute('alt', payload.alt);
|
||||
}
|
||||
if (payload.title) {
|
||||
img.setAttribute('title', payload.title);
|
||||
}
|
||||
|
||||
figure.appendChild(img);
|
||||
|
||||
|
|
|
@ -45,6 +45,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" alt="example image"></figure>');
|
||||
});
|
||||
|
||||
it('renders an image with title attribute', function () {
|
||||
let opts = {
|
||||
env: {
|
||||
dom: new SimpleDom.Document()
|
||||
},
|
||||
payload: {
|
||||
src: 'https://www.ghost.org/image.png',
|
||||
title: '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" title="example image"></figure>');
|
||||
});
|
||||
|
||||
it('renders nothing with no src', function () {
|
||||
let opts = {
|
||||
env: {
|
||||
|
|
Loading…
Reference in a new issue