I'm using tinymce do do some wysiwyg editing on my site. To insert images it displays a drop down list of images which I need to propagate with all the images in a given image directory.
Here's the code in the main script:
"external_image_list_url : tinymce/lists/link_list.js"
And here's link_list.js:
var tinyMCEImageList = new Array(
// Name, URL
["Logo 1", "media/logo.jpg"],
["Logo 2 Over", "media/logo_over.jpg"]
);
Now I need that array to show all the files in the images/dogs directory. Here's the PHP code I'd want to run there:
function getfiles($dirname=".") {
$pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)"; //valid image extensions
$files = array();
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)) //if this file is a valid image
echo "$file <br />";
}
closedir($handle);
}
return($files);
}
How do I get the two to work together?
Hope the question makes sense
ASKER