I created a small and simple Wordpress Plugin to display a random header image. I know the K2 themes provides that - but since I don’t have K2, this is my solution.
Installation
- View the plugin source
- Copy and paste it in a file called “randomizer.php” in your
wp-content/plugins/folder - Create a folder called
header-images/in yourwp-content/folder and give it full access rights (777) - Go to your Plugins admin page and activate the plugin
- That’s it…
Use
When activated you will get under Options –> Header Randomizer an admin interface where you can see if you set up your image folder correctly, you can change the CSS header tag and view the images in your image folder.
And your header image will change of course.
Notes
- I tested it only with WP 2.0.2 but it should work with 1.5 as well.
- If you have questions, bug reports or praise just let me know.
- The size of your header images is defined in your stylesheet. Please look in your CSS file or take a look at your current image size.
Important
If you get a Can’t modify header information warning, remove all spaces before and after the PHP open and close tags at the beginning and end of the file.

Grml, das hättest Du mal vier Wochen eher basteln können, dann hätte ich nicht so lange suchen müssen ;-).
[...] ããHeader Randomizerï¼éæºæ é¢å¾æ¡æ¾ç¤ºã header image randomizer [...]
Das ging ja nicht. Ich hatte das bei Dir gesehen und fand das praktisch…
Ach so.
Hab auch lange gesucht, bis ich ein funktionierendes Plugin gefunden habe. Die, die ich zuerst hatte liefen gut mit dem Standard-Template, aber nicht mit anderen.
hi~i like this plugin.but if i use it ,the “lightbox” can’t work.deactivated it then “lightbox” can show .would u like to help me ? thanks!
@super37: i just installed the wp lightbox plugin 2.02 and it works fine as well as my header image rotation. here is the sample post that uses lightbox.
Thank u. my friend told me to delete this
"if ( !get_settings('gzipcompression') && !ini_get('zlib.output_compression') ) { ob_start('ob_gzhandler'); }"in the “lightbox.css.php\effect.js.php\lightbox.js.php\prototype.js.php”.i don’t know why.but now is fine.
Das ist schon mal genau das, was ich gesucht habe. Leider funktioniert es nicht ganz so wie erwartet. Im Frontend ist alles super. Doch leider kann man sich nicht mehr in die Administration einloggen. Fehler wie dieser:
[code]Warning: Cannot modify header information - headers already sent by (output started at /var/www/webxxx/html/blog/wp-content/plugins/randomizer.php:134) in /var/www/webxxx/html/blog/wp-includes/pluggable-functions.php on line 272[/code]
treten am laufenden Band auf und ich habe noch keine Lösung gefunden außer dem deaktivieren des Plugins. Haste ne Idee, Lennart?
Please help me out here, it doesn’t work with the latest version!
many thanks
kam
Hi,
the error message “cannot modify header information” means to say that there are blank lines or spaces before the first line or after the last. So just delete all blanks before the first opening tag and after the last closing one of php. That should do the job…
Hallo,
coole Sache dieser PlugIn - dennoch bin ich kein begnadeter “programmierer” und hatte soeben eine Fehlermeldung die wie folgt erschienen ist:
Warning: Cannot modify header information - headers already sent by (output started at /home/.sites/127/site752/web/wp-content/plugins/randomizer/randomizer.php:8) in /home/.sites/127/site752/web/wp-includes/pluggable-functions.php on line 272
Was kann das sein? Jeder Rat ist willkommen! Danke!!
Lieben Gruß aus Chile,
John
hahaha - grad mal die anderen comments gelesen und siehe da: same problem same solutions - werds mal ausprobieren - bis gleich!
Ok-alles hat funktioniert - jetzt aber Fehlermeldung im Backend: Warning: Cannot modify header information - headers already sent by (output started at /home/.sites/127/site752/web/wp-content/plugins/randomizer.php:133) in /home/.sites/127/site752/web/wp-admin/inline-uploading.php on line 5
Und das hat anscheinend nichts mehr mit löschen von lines zu tun - oder?
Und genau das steht in line 5 bei inline-uploading.php : header(’Content-Type: text/html; charset=’ . get_option(’blog_charset’));
Also ich blicks momentan nicht durch.
Danke schon im vorraus für jeden Tipp!
Lg,
John
welche wordpress version hast du am start?
Hi,
I downloaded your plugin and activated under admin panel.
It doesn’t work on my theme (in3D 1.0). I noticed that in style.css the code where the logo image is is under #logo.
I tryied to change it under the administration panel CSS ID Tag but nothing changes.
I’m very interested in having a plugin like yours, could you help me?
Thanks for your time and sorry for my english.
Gabriele
[...] Und so hat sich diese Nacht mein Weblog in optischer Hinsicht wieder mal etwas gewandelt… AuÃerdem ist ein neues Plugin hinzugekommen: Der Header Randomizer vom problemloeser. Kommentar schreiben [...]
man kann hier auch auf deutsch schreiben
habe das plugin heute bei mir installiert, funktioniert tadellos. ich habe ‘#logo’ anstatt ‘#header’ im optionsmenü eingegeben und es lief. mmh, weiß leider nicht, woran es liegt dass es bei dir nicht geht.
okay, you dont speak german, i dont speak italiano… mmh, you seem to have the same theme. it did work for me to change the header_id in the admin panel - dont know why it fails for you.
Leider funktioniert es bei mir auch nicht so wie erwartet. Im Frontend ist alles super. Doch leider kann man sich nicht mehr in die Administration einloggen. Fehler wie dieser:
[code]Warning: Cannot modify header information - headers already sent by (output started at /var/www/webxxx/html/blog/wp-content/plugins/randomizer.php:134) in /var/www/webxxx/html/blog/wp-includes/pluggable-functions.php on line 272[/code]
Schade ist sonst ein echt gutes Plugin. Ich hab es erstmal wieder deaktiviert.
very nice job.Thank you
Hi Stefan,
schau doch mal, ob in der randomizer.php oder in der pluggable-functions.php am Anfang oder am Ende Leerzeilen vor bzw. nach den PHP Tags sind. Die bitte löschen…
Klasse nun geht es.
Es war genau ein leerzeichen am ende der Datei randomizer.php vorhanden. gelöscht und siehe da nun funktioniert das plugin - danke ist ein super sache mit dem random tool
So, jetzt hab ich auch nochwas zu motzen. Wenn ich auf die Optionsseite gehe, sehe ich gar nix und bekomme einen nicht näher definierbaren JavaScript-Fehler. Irgendeine Idee? Ansonsten scheint’s zu funktionieren.
OK, gefunden! In Deinem JavaScript-Code steht am Ende immer //->, muß aber //–> sein. Scheinbar hat der IE mit dem fehlenden - ein Problem, weil er dann den Kommentar nicht schließt…
Danke Michael! Ist geändert!
copy&paste ist wohl nicht immer das Wahre
Hi! I am using your plugin on my blog and it looks great… except when someone comments or if i post i get the following message
Warning: Cannot modify header information - headers already sent by (output started at /home/.turgo/rampurple/rampurple.com/blog/wp-content/plugins/randomizer.php:131) in /home/.turgo/rampurple/rampurple.com/blog/wp-includes/pluggable-functions.php on line 194
any advice on what to do?
remove any spaces before and after the the php tags
Lennart I have! I read that info on a previous comment and tried it but it didn’t work :S
Hi, thnaks for your plugin..
I’ve already installed and “working” but the images are behind the Neo-Sapien Theme header image… how could I replace ??
thanks
Rod
I like the concept of this plug, but is it possiple to make it dynamic … so that image changes, say every 20 sec without viewer has to change page.? Also what would be realy need is if the transition would be a fading motion, so one image slowly fades out while the other slowly fades in.
Ich habe auch dieses Problem, dass ich im backend bei “Schreiben” diese Fehlermeldung erhalte:
=======================================
Warning: Cannot modify header information - headers already sent by (output started at C:\Programme\xampp\htdocs\testwp\wp-content\plugins\randomizer.php:133) in C:\Programme\xampp\htdocs\testwp\wp-admin\inline-uploading.php on line 4
Warning: Cannot modify header information - headers already sent by (output started at C:\Programme\xampp\htdocs\testwp\wp-content\plugins\randomizer.php:133) in C:\Programme\xampp\htdocs\testwp\wp-includes\pluggable-functions.php on line 271
=======================================
Den Tipp mit den spaces habe ich natürlich schon beachtet.
WP 2.0.5
Great plugin. I’m using it on a few different site. Thanks! I was wondering if there’s a way to NOT randomize the header image on the homepage (home.php) ?
Hi,
I use your great plugin in a testsite but have one problem. I’m also using the eventcalendar plugin.
If I activate random header the event calendar can’t refresh. Any idea how to solve this?
TIA,
@rko
Hi Lennart,
Dein geniales Plugin läuft nun auch bei mir ohne Probleme - feine Sache das …
… nur leider ist es nicht kompatibel mit dem wirklich hübschen Snowfall-Plugin
http://wpplugins.info/3/snowfall/
oder auf deutsch
http://www.journal.kylaloo.net/2005-12/froher-schneefall
hast Du ne Idee, wie ich beides zu laufen kriege?
Wäre super!
Hi Lennart
I’ve got a question, and hopefully you will be able to help.
I want to change the main color i use for backgrounds and fonts in my theme depending on the random background image.
I was thinking of doing that in the following way:
I will name the background image with the color that I want to use, so
000000.jpg, ffffff.jpg
Now is there a way to change the name of the selected image into a variable (eg $color that I can then use in my css (or add as a declaration in my header) so that
#backgroundbox {
background: #$color;
}
Well - the plugin exchanges the image via javascript, which means this is done at client side, after the page is being created on the server. So you cannot pass it to a php script without loading the page again.
But there is something you can do. You can change the background color with something like this in javascript:
document.bgColor = ‘#ffffff’;
Similar stuff can be done with any other css setting. A good page to get you started is selfhtml (it is german though).
I hope this helps…
Lennart,
Thanks! I want the color of a specific div to change according to the random image. For instance when image A is randomly selected, I want it to turn red, when image B is selected, I want it to turn blue.
Would it otherwise be possible to make seperate .css files that are related to the images in the folder, so the javascript will select image1.jpg and image1.css or image2.jpg and image2.css ?
best
Martijn
i wouldn’t load separate css files, that’s a pain to do. it’s easier to change the css attribute of something of a page.
Another link for you…
Awesome plug-in.
Hi,
I can not the the plugin after copy it to the wp-content/plugins/ folder…
I use WordPress 2.3.2 (DE-Edition)
Any ideas what may be the issue ?
Thx
Hi,
bei 2.3. in der englischen Orginal Version geht alles brav… Hast Du vielleicht die Datei-Rechte nicht auf 644 stehen?
Ich bin quasi ein wordpress frischling und hab mir dein skript installiert.
Installation gelungen, bei “Einstellungen” “Header Randomizer” werden auch die Bilder aufgelistet, aber es tut sich nichts.
Jetzt meine Frage? was sollte im css-id-tag “header” stehen, dass das ganze funktioniert.
Danke im Voraus für die Hilfe.
hi, auf der seite muss nur ein <div id=”header”> stehen. dann sollte es eigentlich gehen. siehe mein blog…
wenns nicht klappt. schicke mir doch einfach den link zu deinem blog.
[...] header randomizer (wordpress plugin) [...]
Super Plugin. Funzt super. Kommpliment
Ich hab es auch aber bei mir wechselt der header nicht. Kannst du mir helfen?