Jump to content

Use random image in Advertisement (or random Advertisement)?


ipbfuck

Recommended Posts

Hi,

i've used an Advertisement by ad key in template, and i need to make a random image in this, same url.

i've try to make another ad with same link and different image, but how i can put randon php code with {advertisement="key"} in template?

something like this:

{{ rand(0, 1) ? '{advertisement="key1"}' : '{advertisement="key2"}'; }}

(untested - just idea...) - i need equivalent in php for ipb: {advertisement="key"} ^_^

Link to comment
Share on other sites

Php script: eg > random_image.php

put image with name image1.jpg; image2.jpg (if u have more, insert in array)

<?php
// random jpg from this folder
header ("Content-Type: image/jpg");

$images = array
(
  "image1",
  "image2"
);
include($images[array_rand($images)].".jpg");
?>

 

html code in advert:

<a href="..." title="link title">
  <img src="...fulllink/dir_with_image/random_image.php" alt="alternative text">
</a>

 

work as expected!

yes, i can use also glob, but glob at every refresh... i think a simple rand - for no more image - can be a best solution :p

 

regards!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...