Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //path to directory to scan. i have included a wildcard for a subdirectory
- $directory = "./";
- //get all image files with a .jpg extension.
- $images = glob("" . $directory . "*.{jpg,png}", GLOB_BRACE);
- $imgs = '';
- // create array
- foreach($images as $image){ $imgs[] = "$image"; }
- //shuffle array
- shuffle($imgs);
- //select first 20 images in randomized array
- $imgs = array_slice($imgs, 0, 1);
- echo "
- <html>
- <head>
- <style>
- img {
- position: fixed;
- top: 0;
- left: 0;
- /* Preserve aspet ratio */
- min-width: 100%;
- min-height: 100%;
- }
- </style>
- </head>
- <body>
- ";
- //display images
- foreach ($imgs as $img) {
- echo "<img src='$img'> ";
- echo "
- </body>
- </html>
- ";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement