From 7e2ff9e0d8da0e5bbb232933d587b08b752e6e72 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sun, 10 Jun 2012 18:09:15 +0100 Subject: [PATCH] Extended the image macro to take a width and height --- core/modules/macros/image.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/modules/macros/image.js b/core/modules/macros/image.js index 056741f5d..f2e23aa08 100644 --- a/core/modules/macros/image.js +++ b/core/modules/macros/image.js @@ -17,7 +17,9 @@ exports.info = { params: { src: {byName: "default", type: "tiddler"}, 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)) { var imageTree = this.wiki.parseTiddler(this.params.src).tree, 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) { return $tw.Tree.Element("div",{ alt: this.params.text, @@ -37,6 +45,8 @@ exports.executeMacro = function() { return $tw.Tree.Element("img",{ src: this.params.src, alt: this.params.text, + width: this.params.width, + height: this.params.height, title: this.params.text }); }