poldesenuoutt
New Member
I'm creating a wordpress meta box and I need to scan a directory of subdirectories containing images within my template and add these to a select dropdown so I can use the filename in my template.The images are currently arranged in the folder like thisarent Folder
|_ Secondary Folder
|_ Image.png
|_ Image.jpg
|_ Image.gif
|_ Secondary Folder
|_ Image.png
|_ Image.jpg
|_ Image.gif
Ideally I'd like to keep that structure in my select dropdown ie.Secondary Folder .
|_ Image.pngI've been using this:\[code\]function get_dir_path(){ return dirname(__FILE__).'/library/images';}$largeImagesdir = get_dir_path() . '/960x345/'; if ($dh = opendir($largeImagesdir)) { while (($file = readdir($dh)) !== false) { $lfiles .= '<option>' . $file . '</option>'; } closedir($dh); } $buildbox .= '<select>' . $lfiles . '</select>';\[/code\]However this of course only works if I set the $largeImagesdir var to be one of the sub directories...Can anyone help?
|_ Secondary Folder
|_ Image.png
|_ Image.jpg
|_ Image.gif
|_ Secondary Folder
|_ Image.png
|_ Image.jpg
|_ Image.gif
Ideally I'd like to keep that structure in my select dropdown ie.Secondary Folder .
|_ Image.pngI've been using this:\[code\]function get_dir_path(){ return dirname(__FILE__).'/library/images';}$largeImagesdir = get_dir_path() . '/960x345/'; if ($dh = opendir($largeImagesdir)) { while (($file = readdir($dh)) !== false) { $lfiles .= '<option>' . $file . '</option>'; } closedir($dh); } $buildbox .= '<select>' . $lfiles . '</select>';\[/code\]However this of course only works if I set the $largeImagesdir var to be one of the sub directories...Can anyone help?