As it stands, the rotate.php script returns then entire image for banners that need rotating. This is a massive waste of bandwidth, especially if there are many banners, or they are high quality. Note that the largest of the included banners is currently avaro.jpg at 106030 bytes.

This problem can be overcome by modifying rotate.php script to return CSS style information that defines the background style for the #header element at random and references a random image file, rather than returning that image file directly. In this way much bandwidth can be saved as the browser will cache referenced image files. The only file not to be cached being the CSS style rotate.php which is now usually less than 100 bytes.

I have made such a change and tested and this works perfectly here.

Instead of rolling a patch which may become outdated, here are the steps to make this improvement:

1. Remove the #header style from graphics.css. This line (which is line 20 in my version):

#header {background: #000033 url(img/banners/rotate.php) no-repeat 0px 0px; /*rotates images in the banners folder */}

2. Replace the rotate.php script in img/banners directory with the one attached. Note due to upload restrictions on Drupal.org remember to rename the file appropriately.

3. Place the following line at the bottom of template.php to reference the dynamically updating rotate.php:

drupal_add_css(drupal_get_path('theme','marinelli').'/img/banners/rotate.php', 'theme', 'all', FALSE);

Enjoy the bandwidth and speed savings!

CommentFileSizeAuthor
rotate.php_.txt935 bytesraintonr

Comments

Pok’s picture

Thanks for the great tip raintonr. I am always eager to save some bandwidth or make my sites more "snappy"...

However, have you also tested this new approach on various browsers to ensure it won't break anything?

I would like to know if it works on Firefox, Chrome, Safari ..and Internet Explore 6 - 8.

Cheers,
Paul

raintonr’s picture

Re: #1. Well - it worked on Firefox & Chrome. There's no reason this shouldn't work on any standards compliant browser. You might want to check IE then ;)

Pok’s picture

..any standards compliant browser. You might want to check IE then ;)

hehe so true.. ;-) When I find the time I will test it out and post my results back here. Thanks again!

tjharman’s picture

Thank you!

I just went in search of how to fix this myself and you've already done it.

Thank you so much!

Working perfectly here.

Tim

hojoeast’s picture

I wonder if this solution will also correct the problem with FF 3.6 described in the issue: rotate.php does not work correctly in Firefox 3.6 ?

hojoeast’s picture

As I thought, this solution also fixes the problem described with rotate.php and Firefox 3.6. This problem is in drupal.org/node/713188.

nick johnson’s picture

This is pure genius.

falmela2’s picture

I've been thinking about this for days and here it is, a perfect solution. Thanks a lot.

brianwilson71’s picture

Just wondering if this has been included with version 7, or does that patch still need to be applied?

Thanks,

/Brian

oadaeh’s picture

Status: Active » Closed (won't fix)

This issue is being closed because it is against a branch for a version of Drupal that is no longer supported.
If you feel that this issue is still valid, feel free to re-open and update it (and any possible patch) to work with the 7.x-4.x branch.
Thank you.