mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 17:10:29 +00:00
Extended the image macro to take a width and height
This commit is contained in:
parent
298b10b8f9
commit
7e2ff9e0d8
@ -17,7 +17,9 @@ exports.info = {
|
|||||||
params: {
|
params: {
|
||||||
src: {byName: "default", type: "tiddler"},
|
src: {byName: "default", type: "tiddler"},
|
||||||
text: {byName: true, type: "text"},
|
text: {byName: true, type: "text"},
|
||||||
alignment: {byName: true, type: "text"}
|
alignment: {byName: true, type: "text"},
|
||||||
|
width: {byName: true, type: "text"},
|
||||||
|
height: {byName: true, type: "text"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -25,6 +27,12 @@ exports.executeMacro = function() {
|
|||||||
if(this.wiki.tiddlerExists(this.params.src)) {
|
if(this.wiki.tiddlerExists(this.params.src)) {
|
||||||
var imageTree = this.wiki.parseTiddler(this.params.src).tree,
|
var imageTree = this.wiki.parseTiddler(this.params.src).tree,
|
||||||
cloneImage = imageTree[0].clone();
|
cloneImage = imageTree[0].clone();
|
||||||
|
if(this.hasParameter("width")) {
|
||||||
|
cloneImage.attributes.width = this.params.width;
|
||||||
|
}
|
||||||
|
if(this.hasParameter("height")) {
|
||||||
|
cloneImage.attributes.height = this.params.height;
|
||||||
|
}
|
||||||
if(this.params.text) {
|
if(this.params.text) {
|
||||||
return $tw.Tree.Element("div",{
|
return $tw.Tree.Element("div",{
|
||||||
alt: this.params.text,
|
alt: this.params.text,
|
||||||
@ -37,6 +45,8 @@ exports.executeMacro = function() {
|
|||||||
return $tw.Tree.Element("img",{
|
return $tw.Tree.Element("img",{
|
||||||
src: this.params.src,
|
src: this.params.src,
|
||||||
alt: this.params.text,
|
alt: this.params.text,
|
||||||
|
width: this.params.width,
|
||||||
|
height: this.params.height,
|
||||||
title: this.params.text
|
title: this.params.text
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user