View Full Version : Help with placing ads inside an image

06-05-2010, 12:40 PM
Hi guys,

Could someone please tell me how I can place an ad inside an image?

Something similar to this: http://berrycorp.biz/freelance.php
Please wait a few secs for th epage to load so you can see the function (ads inside images) that I am looking for.

any help will be much appreacited.

Thank You
Kind Regards

06-05-2010, 05:15 PM
Why is this a question for PHP? This should be possible using CSS.

I don't understand exactly what you want-- just place one image over another image? That's using z-index and position:absolute (probably).

06-06-2010, 10:37 AM

No, I don't need place an image in another image. that is easy done using AP DIVS.

I need a PHP code to be able to place within the current codes in the page and the code will automatically detect images and place ads on within the image simialr to the one that I showed above.

I put it PHP section because I thought this could be done using PHP. If you have any other suggestions then I'd love to hear that mate...

Thank You
Kind Regards

06-06-2010, 07:52 PM
Ah, I think I understand now.

But would this be a lot easier manually?

How will you determine which images to use? Just every image on the page? What about small images that won't fit the ad?

Anyway, you can approach this two ways:

1. Server side language (like PHP): read the entire page as HTML into an array. This means using an output buffer or some form of advanced templating. After you read it into HTML as some sort of object (array, class, etc) you can loop through each element and find which ones are 'img'-- then just add a new 'img' tag next to that.

2. Use Javascript. There are some disadvantages here, mostly that your visitors will need JS enabled. However, this is MUCH easier than doing it with PHP, because Javascript can work with the active page and not need to add an extra step in the process. This also is nice because Javascript already sees the page as elements so you don't need to parse it, but just loop through them.

Doing this with Javascript may be reasonable, but I really don't think there's much point of using PHP. It's more effort than it's worth, probably.