Get image width for uploaded image

I have been trying to do this in javascript and set a variable but I can't get it to work (with chatGPT's help).

There should be an easy way to pass the url of the uploaded image and get the width dimension right?

I also need to do it to get the height dimension.
Was this page helpful?