title: Run script when image is loaded
body: <p>Is there a way to run code when an image is loaded?</p>
  
  <p>For example when if my image is hosted at www.mydomain.com/image.png and if someone executes this link image will be displayed as this is an image file. But, can I run a set of code when someone trying to view an image?</p>
  
  <p>Like. </p>
  
  <p>When I open run www.mydomain.com/image.png it should perform something like</p>
  
  <pre><code>&lt;?php
    mail("myemail@mydomain.com", "image opened", "image opened by".$Server['addr']);
  ?&gt;
  </code></pre>
  
  <p>I found there are multiple such services offered online but I am unable to sort out how to execute a code file when image file is trying to be executed.</p>
  
  <p>Can anyone give me a brief idea how this will workout? I can code on my own a</p>