It is against the Adsense TOS to draw attention to the ads in any inappropriate way. However, many people have found that placing images in the near vicinity can increase CTR. However, how do you keep those images fresh?
This code will create image rotation which you can use to rotate images beside adsense ads. That way they never get stale. You could also use it for some ads rotation if you're not using adense or otherwise.
<?php
$path_to_images = "images/"; // this is path to your images
$default_img = "box.gif"; // default image to display if directory listing fails
function getRandomImage($path, $img) {
if ( $list = getImagesList($path) ) {
mt_srand( (double)microtime() * 1000000 );
$num = array_rand($list);
$img = $list[$num];
} return $path . $img;
}
function getImagesList($path) {
$ctr = 0;
if ( $img_dir = @opendir($path) ) {
while ( false !== ($img_file = readdir($img_dir)) ) {
// can add checks for other image file types here
if ( preg_match("/(\.gif|\.jpg)$/", $img_file) ) {
$images[$ctr] = $img_file;
$ctr++;
}
}
closedir($img_dir);
return $images;
} return false;
}
?>