Googlify your site banner

Do you like the way that Google changes its masthead for special occasions? Would you like to do this on your site?

Daisy and I have the solution for you and it’s all rather simple (he says, ignoring the schoolboy error that flummoxed him for far too long earlier).

For this script to work you will need the script in your theme’s folder and a default banner that’s used if no bespoke files are found.

To keep things tidy you may want to have your banners in a subdirectory, in which case you need to specify the directory.

Bespoke banners can be set for specific dates, day/month combinations or for months.

You must have a consistent convention for naming your banner images, starting with a prefix, e.g. “pic”

You can then have bespoke banners by following these rules:

PREFIX+YEAR+MONTH+DAY.jpg
will display on one day only
PREFIX+MONTH+DAY.jpg
will display on a given date each year unless there’s a separate image for that Day/Month/Year
PREFIX+MONTH.jpg
will display for a calendar month (unless one of the higher priority cases is matched).

e.g. if the prefix for banners is “pic” you could have:

  • pic20051229.jpg to display on 29th December 2005 only
  • pic0603.jpg would be displayed on every 3rd of June, and
  • pic06.jpg will display during the month of June EXCEPT for the 3rd as the previous file will take priority

Finally, in your CSS you’ll need something like:

#top { background: transparent url(banner.php) no-repeat top center; width: 490px; height: 185px; }

(with sizes adapted to your banner sizes, of course) and a suitable <div id="top">&nbsp;</div> in your header template.

Here’s a zipped version of the script along with a very basic sample HTML file.

Have fun and please let one of us know if you use this.

 

One response


  1. oh my! if only i had this a couple of years ago…

    well done you two! :)

Leave a Reply