This question has been answered by sottwell. See the first response.
<img src="[[!GetImage]]" />
/* Get Image snippet */ include MODX_CORE_PATH . 'components/dirwalker/model/dirwalker/dirwalker.class.php'; $searchStart = 'path/to/your/image/dir'; $recursive = false; // set to true to search child directories $dw = new DirWalker(); $dw->setIncludes('.gif,.jpg,.png'); // list of strings required in filename // $dw->setExcludes('.git,-all,-min'); // anything you want to exclude // $dw->setExcludeDirs('cache,setup,_build,packages,.git'); $dw->dirWalk($searchStart, $recursive); $fileArray = $dw->getFiles(); $files = array_keys($fileArray); return array_rand($files);