Hello,
So many of you have helped me so I thought I would share this with everyone. Whenever possible I like to automate the width and height attribuites being input by users for images and here is how its done.
First I create a function in a shared FormAPI script library and include it in my DCT that looks like this:
function doPreload(imgObj,imgSrc) {
if (document.images) {
eval(imgObj + ' = new Image()');
eval(imgObj + '.src="' + imgSrc + '"');
}
}
I then use FormAPI to get the image path that the user has input onchange. Next I use the function to preload the image. Now that I've created an object I can get at its properties and then set the width and height fields in the DCT automatically. Like this..
//Set value of Image fields
IWEventRegistry.addItemHandler("/Image", "onItemChange", setImage);
function setModelImage() {
var strImagePath = IWDatacapture.getItem("/Image").getValue();
doPreload('objImage',strImagePath);
setTimeout('IWDatacapture.getItem("/Image Width").setValue((objImage.width))',1000);
setTimeout('IWDatacapture.getItem("/Image Height").setValue((objImage.height))',1000);
}
Hope this helps.