I get an error about 1 out of every 6 times I load my site using four seasons that crashes the header image and says:

Undefined offset: -1 in fourseasons_show_banner() (line 143 of sites/all/themes/fourseasons/template.php).

Is there anything I can do to fix this? I have built a great site with this theme, but obviously can't have people greeted with no banner image and an error message. Any advice would be greatly appreciated!

Comments

aiw_2000’s picture

Status: Active » Needs review

I had the same problem. The issue only occurs if you have more than one header image. The code calculating the random image number is incorrect on line 141:

        default:
                $i = rand(0, $_numbanners) -1;

If rand() chooses "0", then $i becomes -1, hence the error reported. The fix is to simply move the "-1" as follows:

        default:
                $i = rand(0, $_numbanners -1 );

The code now works as intended with no errors.

ccentenrun’s picture

Thanks!!! :)