mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 21:39:57 +00:00
c91fa95843
Surprisingly, it worked fine with HREF in mode browsers.
45 lines
910 B
JavaScript
45 lines
910 B
JavaScript
/*\
|
|
title: js/macros/image.js
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true */
|
|
"use strict";
|
|
|
|
var Renderer = require("../Renderer.js").Renderer;
|
|
|
|
exports.macro = {
|
|
name: "image",
|
|
params: {
|
|
src: {byName: "default", type: "tiddler"},
|
|
text: {byName: true, type: "text"},
|
|
alignment: {byName: true, type: "text"}
|
|
},
|
|
execute: function() {
|
|
if(this.store.tiddlerExists(this.params.src)) {
|
|
var imageTree = this.store.parseTiddler(this.params.src).nodes,
|
|
cloneImage = [];
|
|
for(var t=0; t<imageTree.length; t++) {
|
|
cloneImage.push(imageTree[t].clone());
|
|
}
|
|
if(this.params.text) {
|
|
return [Renderer.ElementNode("div",{
|
|
alt: this.params.text,
|
|
title: this.params.text
|
|
},cloneImage)];
|
|
} else {
|
|
return cloneImage;
|
|
}
|
|
} else {
|
|
return [Renderer.ElementNode("img",{
|
|
src: this.params.src,
|
|
alt: this.params.text,
|
|
title: this.params.text
|
|
})];
|
|
}
|
|
}
|
|
};
|
|
|
|
})();
|