[Resolved] Rotating background fails – except in Edge

Home Forums Support Rotating background fails – except in Edge

  • This topic has 4 replies, 2 voices, and was last updated 4 years ago by Hans.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #273000

    I use the following php in wp-head:

    <?php if ( is_home()  || is_front_page()) : ?>
    <img src='http://huppenbroich.de/wp-content/uploads/hintergrundbilder/rotate.php' id='ktgbild' alt=''>
    <?php endif; ?>

    This works fine in edge – but not in Chrome, Opera, Firefox. It doesn’t change the picture and works in an endless loop.

    rotate.php is a standard routine which worked fine in other installations with generatepress.

    This is my site.

    What might be the problem???

    GeneratePress 1.3.44
    GP Premium 1.2.94
    Lead Developer
    Lead Developer

    Not sure what rotate.php does, but I would do it this way:

    $headers = array(
    $random = $headers[ rand( 0, count( $headers ) -1 ) ];
    	body{background-image:url('<?php echo $random; ?>');background-size:cover;}

    Hi Tom,

    unfortunately this is very uncomfortable as I change the background very often. Could you please have a look at rotate:

    By Matt Mullenweg > http://photomatt.net
    Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
    Latest version always at:
    */// Make this the relative path to the images, like "../img" or "random/images/".
    // If the images are in the same directory, leave it blank.
    $folder = '';
    // Space seperated list of extensions, you probably won't have to change this.
    $exts = 'jpg jpeg png gif';
    $files = array(); $i = -1; // Initialize some variables
    if ('' == $folder) $folder = './';
    $handle = opendir($folder);
    $exts = explode(' ', $exts);
    while (false !== ($file = readdir($handle))) {
    foreach($exts as $ext) { // for each extension check the extension
    if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
    $files[] = $file; // it's good
    closedir($handle); // We're not using it anymore
    mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
    $rand = mt_rand(0, $i); // $i was incremented as we went along
    header('Location: '.$folder.$files[$rand]); // Voila!

    I really wonder what could be the reason.

    Lead Developer
    Lead Developer

    That script was last updated in 2003.

    You’re definitely better off going with a more modern approach.


    It seems to be a caching problem. The editors handle it differently.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.