User:Jasper Deng/Random logo

From mediawiki.org

For fun, I randomized my logo so that users would get a random logo when viewing my wiki. My implementation made use of the rand PHP function.

Doing it yourself[edit]

In LocalSettings.php, replace

$wgLogo             = "$wgStylePath/common/images/wiki.png"; #or whatever existing logo you have

with

$wgLogoNumber = rand(1, n); #(replace n with the number of logos you want to include as a randomization or 
                         # otherwise the number of possible outcomes you want from this)
switch($wgLogoNumber){
    case 1:
        $wgLogo = "<path to logo 1>";
        break;
    case 2:
        $wgLogo = "<path to logo 2>";
        break;
    case 3:
        $wgLogo = "<path to logo 3>";
        break;
//insert as many up to
    case n:
        $wgLogo = "<path to logo n>";
        break;
}

To make the probabilities unequal:

$wgLogoNumber = rand(1, n);
if ($wgLogoNumber >= 1 && $wgLogoNumber <= 2){
    $wgLogo = "<path to logo that is given double weight>";
}
if ($wgLogoNumber === 3){
    $wgLogo = "<path to logo given normal weight>";
}

etc. up to n

Disclaimer[edit]

This hack is neither sanctioned nor officially supported by MediaWiki developers. There may be performance impacts on large wikis.