If you don't deny using a framework like jQuery, there is a triggerHandler () function that should do what you need.
You will need a test to check if the image is uploaded to your script (it should find information on how to do this using Google) - if it has not been uploaded, just attach the onload event handler; if it was loaded, you can either attach an onload event handler, or then run it using the jQuery triggerHandler () function, or execute a code / function that would be executed by the onload event handler, which most of all depends on the handler onload events.
source
share