Search code examples
phpwordpressfile-browser

WordPress or PHP script to pick an image file from a plugin folder


I'm creating a WordPress plugin that allows a user to select one of several image files that are distributed with it. Is there a simple technique for allowing the user to view the files in a filebrowser-like interface and pick one? I want it to look as similar as possible to picking a file in the normal file upload dialog.


Solution

  • I ended up adapting the code from this filebrowser that utilizes scandir. It has a nice simple interface and the code is simple enough to incorporate into a plugin.