Un bout de code pour défiler un repertoire d'images dans une page web en php:
(Ume image chaque 4 secondes)
(Ume image chaque 4 secondes)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | <head> <title>Defilement images</title> <meta name= "author" content= "Wassim Jied coderspirit.blogspot.com" /> </head> <body onLoad= "rotate();" > <?php $directory_name = "./themes/matrice/img/" ; $extensions_ok = array ( ".jpg" , "jpeg" , ".gif" , ".png" ); $folder = opendir ( $directory_name ); $i = 0; $photos = array (); while ( $file = readdir ( $folder )) { if (in_array( strtolower ( substr ( $file , -4)), $extensions_ok )) $photos [] = $directory_name . "/" . $file ; } closedir ( $folder ); $count_photos = count ( $photos ); ?> <script type= "text/javascript" > var rotate_delay = 4000; /*delais en microseconde (4000 = 4 secs)*/ var current = -1; var photos = [<?php for ( $i =0; $i < $count_photos ; $i ++) { echo "\"" . $photos [ $i ]. "\"" ; if ( $i != $count_photos -1) echo "," ; } ?>]; function next() { if (current<photos.length - 1) ++current; else current = 0; } function rotate() { if (photos.length > 0) { next(); document.images.slides.src = photos[current]; window.setTimeout( "rotate()" , rotate_delay); } } /*Original code from http://www.developpez.net/forums/d770199/webmasters-developpement-web/javascript/apercu-image-pop-up/ Thanks to the author , modified by WJ*/ function popImage(largeur,hauteur,options){ var top = (screen.height-hauteur)/2; var left = (screen.width-largeur)/2; window.open(document.images.slides.src, "_blank" , "top=" +top+ ",left=" +left+ ",width=" +largeur+ ",height=" +hauteur+ "," +options); } </script> <center> <table> <tr> <td> <span class = "Apple-tab-span" style= "white-space: pre;" > </span><img src= "/" id= "slides" onclick= "javascript:popImage(730,620,'menubar=no,scrollbars=yes,statusbar=yes')" style= "cursor:pointer;" /> <span class = "Apple-tab-span" style= "white-space: pre;" > </span> </td> </tr> </table> </body> <br> |