1 2 3 4 5 6 7 8 9 10 11 12 13 | $folder =opendir(WB_PATH.MEDIA_DIRECTORY. '/' . $dir . '/.' ); $names = array (); while ( $file = readdir( $folder )) { $ext = strtolower ( substr ( $file ,-4)); if ( $ext == ".jpg" || $ext == ".gif" || $ext == ".png" ){ $names [ count ( $names )] = $file ; } } closedir ( $folder ); shuffle( $names ); $image = $names [0]; $name = substr ( $image ,0,-4); return '<img src="' .WB_URL.MEDIA_DIRECTORY. '/' . $dir . '/' . $image . '" alt="' . $name . '" width="' . $width . '" height="' . $height . '"/>' ; |