How should I create embed code to display my photos on someone else's website?

I have many photos already stored on my website and I want to allow other people to publish any of these photos on their own websites. What I’m trying to do is create embed code for each photo to allow third parties to publish a photo within an iframe (I’m using PHP). It’s just like what Getty Images have done here - allowing others to embed their photos.

Getty’s embed code uses an iframe with the source to the image/webpage being something like this:


My problem is that I don’t know the best way to create/reference the image/page. Getty has created a new page to host each individual image which can be found at the above URL. This page also allows them to add captions etc. My images are not in a database, they are just contained in certain folders and I display them on my website with a foreach/glob script.

To display the iframe’s target source page, I could create a PHP template which is given the unique image file name by the embed code. So the iframe target source would be something like this:


The PHP template then displays the correct image and any appropriate image meta data. I’m sure this comes with lots of security implications - is there a better way to do this?