This section contains detailed articles elaborating on some of the common issues phpBB users encounter while using the product. Articles submitted by members of the community are checked for accuracy by the relevant phpBB Team. If you do not find the answer to your question here, we recommend looking through the Support Section as well as using the Site Wide Search.

Adding a Random Header Image

Description: Want to spice up your board's header with a random header image? Read this article for how to do it.

In Categories:

Link to this article: Select All
[url=https://www.phpbb.com/support/docs/en/3.0/kb/article/adding-a-random-header-image/]Knowledge Base - Adding a Random Header Image[/url]

This article has been updated in the [How To] Modify prosilver's header (under the "Add a Random Header Image" section). Please refer to that topic for instructions. This article has been kept in its original format for archival purposes. t_backoff





Adding a Random Header Image

Hello.

One common request I often see is how to add a random header image or otherwise known as a site logo. A random site logo is a fast and easy way to make your board stand out. An easy way to have multiple site logos is to maybe add a saying underneath your image. For example, you could add something like "We're glad you are here!" or "The friendliest board on the web!"

Step 1

Gather your images together and rename them in this format: site-logo-NUMBER-HERE.extension Replace NUMBER-HERE with a number starting with 1 and of course use the appropriate extension like JPG, PNG, or GIF (note: it's not recommended to use BMP images as they are not universally supported). (You will need to save all images in the same format like PNG.) So you should now have several images ready to be uploaded like site-logo-1.png, site-logo-2.png, site-logo-3.png, site-logo-X.png ....

Step 2

With your favourite text editor, open includes/functions.php and find this line:

Code: Select all

      'T_STYLESHEET_NAME'      => $user->theme['theme_name'],


After that line add this code:

Code: Select all

      'SITE_LOGO_RANDOM'      => mt_rand(1, NUMBER-OF-IMAGES),


Replace NUMBER-OF-IMAGES with the total site logo images you have -- if you have 4 images then use this code:

Code: Select all

      'SITE_LOGO_RANDOM'      => mt_rand(1, 4),


Step 3

Again, with your text editor open, open styles/your style name here/template/overall_header.html and find this line:

Code: Select all

<a href="{U_INDEX}" title="{L_INDEX}" id="logo">{SITE_LOGO_IMG}</a>


Replace {SITE_LOGO_IMG} with this:

Code: Select all

<img src="{T_IMAGESET_PATH}/site-logo-{SITE_LOGO_RANDOM}.EXTENSION" alt="Logo" title="Logo" />


Replace EXTENSION with your image's extension.

Step 4

Upload the changed files to your server and upload your images to the styles/your style name here/imageset directory. If you don't see your new logos after refreshing the page in your browser several times, then you may need to refresh your board's cache, so go to your ACP -> Styles -> Templates -> Refresh. If you still can't see the new images, clear your browser's cache as well and restart it.

As always, practice safe MODding by making a backup of ALL files before you edit them!

Enjoy! :mrgreen: