Posted By

hamsterbacke82 on 12/22/10


Tagged

php files tinymce opendir


Versions (?)

Parse files in a directory and output list (example: tinymce emoticons/emotions)


 / Published in: PHP
 

run this from plugins/emotions and copy/paste the output to emotions.htm

  1. <?php
  2. $handle=opendir("img");
  3.  
  4. $i = 0;
  5. while (($file = readdir($handle))!==false) {
  6.  
  7. $imagesizes = getimagesize('img/'.$file);
  8. $width = $imagesizes[0];
  9. $height = $imagesizes[1];
  10.  
  11. echo " <td><a href=\"javascript:EmotionsDialog.insert('$file','$file-0');\"><img src=\"img/$file\" width=\"$width\" height=\"$height\" border=\"0\" alt=\"{#$file-0}\" title=\"{#$file-0}\" /></a></td>"."\n";
  12. if( $i%4 == 0 ) {
  13. echo '</tr>';
  14. }
  15. if( ($i+4)%4 == 0 ) {
  16. echo '<tr>'."\n";
  17. }
  18.  
  19. $i++;
  20. }
  21.  
  22. closedir($handle);
  23. ?>

Report this snippet  

You need to login to post a comment.