Skip to content

Commit

Permalink
add width and height parameters to image()
Browse files Browse the repository at this point in the history
  • Loading branch information
christianp committed Jan 5, 2022
1 parent ce36441 commit 43e50a4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion runtime/scripts/jme-builtins.js
Expand Up @@ -291,11 +291,19 @@ newBuiltin('html',[TString],THTML,null, {
newBuiltin('isnonemptyhtml',[TString],TBool,function(html) {
return util.isNonemptyHTML(html);
});
newBuiltin('image',[TString],THTML,null, {
newBuiltin('image',[TString, '[number]', '[number]'],THTML,null, {
evaluate: function(args,scope) {
var url = args[0].value;
var width = args[1];
var height = args[2];
var img = document.createElement('img');
img.setAttribute('src',url);
if(width.type != 'nothing') {
img.style.width = width.value+'em';
}
if(height.type != 'nothing') {
img.style.height = height.value+'em';
}
var subber = new jme.variables.DOMcontentsubber(scope);
var element = subber.subvars(img);
return new THTML(element);
Expand Down

0 comments on commit 43e50a4

Please sign in to comment.