Hello
I am trying to provide a preview mechinsm for users who will upload images.
This is what my code looks like:
here is my JavaScript code:
The problem is that sometimes the onload event gets fired and sometimes it doesn't. I am not sure why.
The displayPreview function gets called everytime so the onchange event is working correctly.
In times when the onload event is not triggered and thus setImageDimensions is not called, the newly loaded image is displayed using the dimensions of the previous loaded images (or the placeholder if it happens on the first upload) which may cause the image to become distorted.
help is appreciated