Allow other websites use my photos through Javascript

I want to create a Javascript system or something like that which let other websites use photos from my website for free, but I want to be able to add an advertisment on their page.

I can make it through an iframe I guess:

<iframe src="<?php echo $embedCode; ?>" width="100%" height="690"frameborder="0" scrolling="no" allowfullscreen></iframe>

This should be the code other websites may use to print photos on their website. Any ideas how may I accomplish something like this?