Guest User

Untitled

a guest
Feb 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <?
  2. function returnimages($dirname="<$MTBlogSitePath$>images/beadcolors/") {
  3. $pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)";
  4. $files = array();
  5. $curimage=0;
  6. if($handle = opendir($dirname)) {
  7. while(false !== ($file = readdir($handle))){
  8. if(eregi($pattern, $file)){ //if this file is a valid image
  9. //Output it as a list of linked images
  10. $name=eregi_replace($pattern,'',$file);
  11. $colorname=eregi_replace('_',' ',$name);
  12. echo '<a href="javascript:void(0);" onclick="addcolor(\''.$colorname.'\');" title="'.$colorname.'"><img src="/images/beadcolors/'.$file.'" alt="'.$colorname.'" /></a>';
  13. echo "\n";
  14. $curimage++;
  15. }
  16. }
  17.  
  18. closedir($handle);
  19. }
  20. return($files);
  21. }
  22.  
  23. returnimages() //Output the array elements containing the image file names
  24. ?>
Add Comment
Please, Sign In to add comment