misuzu/assets/misuzu.js/embed/image.js

35 lines
766 B
JavaScript

#include utility.js
const MszImageEmbed = function(metadata, options, target) {
options = options || {};
const image = $e({
tag: 'img',
attrs: {
alt: target.dataset.mszEmbedAlt || '',
src: metadata.url,
},
});
const pub = {
getElement: function() {
return image;
},
appendTo: function(target) {
target.appendChild(image);
},
insertBefore: function(ref) {
$ib(ref, image);
},
nuke: function() {
$r(image);
},
replaceElement(target) {
$ib(target, image);
$r(target);
},
getType: function() { return 'external'; },
};
return pub;
};