mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-11 09:53:32 +03:00
d29e376367
No issue
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
module.exports = {
|
|
name: 'image',
|
|
type: 'dom',
|
|
render(opts) {
|
|
let payload = opts.payload;
|
|
// let version = opts.options.version;
|
|
let dom = opts.env.dom;
|
|
|
|
if (!payload.src) {
|
|
return '';
|
|
}
|
|
|
|
let figure = dom.createElement('figure');
|
|
let figureClass = 'kg-card kg-image-card';
|
|
if (payload.cardWidth) {
|
|
figureClass = `${figureClass} kg-width-${payload.cardWidth}`;
|
|
}
|
|
figure.setAttribute('class', figureClass);
|
|
|
|
let img = dom.createElement('img');
|
|
img.setAttribute('src', payload.src);
|
|
img.setAttribute('class', 'kg-image');
|
|
if (payload.alt) {
|
|
img.setAttribute('alt', payload.alt);
|
|
}
|
|
if (payload.title) {
|
|
img.setAttribute('title', payload.title);
|
|
}
|
|
|
|
figure.appendChild(img);
|
|
|
|
if (payload.caption) {
|
|
let figcaption = dom.createElement('figcaption');
|
|
figcaption.appendChild(dom.createRawHTMLSection(payload.caption));
|
|
figure.appendChild(figcaption);
|
|
}
|
|
|
|
return figure;
|
|
}
|
|
};
|