Get Image Dimensions From Image-Src

Is there a way to get the height/width from an Image’s src?

Is it an image you uploaded to Wix or an external image from a different website?

I am interested in that issue, on my site, images are uploaded by customer from their own PC, on a form, and I want to control their width and height while uploading them

Thank to anyone who has an idea…

Yes, this is possible if you know some coding. We can control the image when the customer uploads it by using the onChange event. We can show an error message if the uploaded image doesn’t meet the required width and height. For this, you will need to write both page code and backend code.

Thank you to be interested in my question.

I use velo, and I write page code. But I can’t find the way to get the height/width from an Image’s src, can you tell me a bit more?

To get the height and width of an image from its src in Wix Code, you can use an HTML element to run custom JavaScript. Dynamically load the image via a JavaScript Image object, listen for its onload event, and then retrieve its dimensions using built-in properties like naturalWidth and naturalHeight.

If you’d like more help or specific guidance, feel free to reach to me at : Share on WhatsApp

I’m afraid I am not able to do that without any sample. No one has ever encountered the same problem?

I understand that , we can help you with the problem
let’s connect at : Calendly - Debarun Acharya

We will need to find an API that allows us to determine the dimensions of an image.

Thank you najmazahid, I have found the right one: handlePhotoUpload, thanks to Mark_Hunte, in another post (it’s bad, but I was so disturbed with that issue that I created two similar posts, sorry)

1 Like