I have a php script that randomly generates an image. Something like this:
To use the image inside the src attribute you need to provide a valid URI, for example a data-URI:
src
I once compiled a more detailed answer for a similar question.