Is there a way to incorporate the width and height of an uploaded image into the HTML img src at the bottom of my page using jQuery within Umbraco?
<script>
function getMeta(varA, varB) {
if (typeof varB !== 'undefined') {
alert(varA + ' width ' + varB + ' height');
} else {
var img = new Image();
img.src = varA;
img.onload = function () {
getMeta(this.width, this.height);
}
}
}
getMeta("@image.Url()")
</script>
<img src="@image.Url()" width="" height="" border="0" alt="@Model.Value("mapImage")
mapImage" usemap="#Map" />
The width and height attributes are currently left empty, but I need them to be populated with the dimensions of the uploaded image. These values should be dynamic based on the size of the image for other functions as well.
Any help would be greatly appreciated. Thank you :)