- This topic has 4 replies, 2 voices, and was last updated 7 years, 2 months ago by Hans.
Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
February 1, 2017 at 1:51 pm #273000Hans
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???
February 1, 2017 at 4:30 pm #273050TomLead DeveloperLead DeveloperNot sure what rotate.php does, but I would do it this way:
<?php $headers = array( 'http://yourwebsite.com/URL/TO/header1.jpg', 'http://yourwebsite.com/URL/TO/header2.jpg', 'http://yourwebsite.com/URL/TO/header3.jpg', 'http://yourwebsite.com/URL/TO/header4.jpg', ); $random = $headers[ rand( 0, count( $headers ) -1 ) ]; ?> <style> body{background-image:url('<?php echo $random; ?>');background-size:cover;} </style>
February 1, 2017 at 10:37 pm #273107HansHi Tom,
unfortunately this is very uncomfortable as I change the background very often. Could you please have a look at rotate:
<?php /* By Matt Mullenweg > http://photomatt.net Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php Latest version always at: http://photomatt.net/scripts/randomimage */// 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 ++$i; } } } 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.
February 1, 2017 at 11:53 pm #273120TomLead DeveloperLead DeveloperThat script was last updated in 2003.
You’re definitely better off going with a more modern approach.
February 2, 2017 at 1:01 am #273134HansIt seems to be a caching problem. The editors handle it differently.
-
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.