Advertisement
tirabytes

HTML: Full Screen any image

Apr 1st, 2019
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.71 KB | None | 0 0
  1. <?php
  2. //path to directory to scan. i have included a wildcard for a subdirectory
  3. $directory = "./";
  4.  
  5. //get all image files with a .jpg extension.
  6. $images = glob("" . $directory . "*.{jpg,png}", GLOB_BRACE);
  7.  
  8. $imgs = '';
  9. // create array
  10. foreach($images as $image){ $imgs[] = "$image"; }
  11.  
  12. //shuffle array
  13. shuffle($imgs);
  14.  
  15. //select first 20 images in randomized array
  16. $imgs = array_slice($imgs, 0, 1);
  17.  
  18. echo "
  19. <html>
  20. <head>
  21. <style>
  22. img {
  23.   position: fixed;
  24.   top: 0;
  25.   left: 0;
  26.    
  27.   /* Preserve aspet ratio */
  28.   min-width: 100%;
  29.   min-height: 100%;
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. ";
  35. //display images
  36. foreach ($imgs as $img) {
  37.     echo "<img src='$img'> ";
  38. echo "
  39. </body>
  40. </html>
  41. ";
  42.  
  43. }
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement