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!
| Comment | File | Size | Author |
|---|---|---|---|
| rotate.php_.txt | 935 bytes | raintonr |
Comments
Comment #1
Pok commentedThanks 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
Comment #2
raintonr commentedRe: #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 ;)
Comment #3
Pok commentedhehe so true.. ;-) When I find the time I will test it out and post my results back here. Thanks again!
Comment #4
tjharman commentedThank 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
Comment #5
hojoeast commentedI 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 ?
Comment #6
hojoeast commentedAs I thought, this solution also fixes the problem described with rotate.php and Firefox 3.6. This problem is in drupal.org/node/713188.
Comment #7
nick johnson commentedThis is pure genius.
Comment #8
falmela2 commentedI've been thinking about this for days and here it is, a perfect solution. Thanks a lot.
Comment #9
brianwilson71 commentedJust wondering if this has been included with version 7, or does that patch still need to be applied?
Thanks,
/Brian
Comment #10
oadaeh commentedThis 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.