7
Absolutely doable with PHP code embedded in your templates. Below is an example for what I did for one site. This code reads files from a (definable) directory, selects one randomly, and returns the filename. The code supports multiple themes (drawing from a callable directory within the theme directory) and allows usage/calls in multiple locations in the theme. However, it's not designed to provide size information (height/width) on different file sizes.
First, define the function somewhere in your theme file:
le="color: #000000"><?php <{php}> function getRndImgURL($path) { // Display Random Image from File Path $i = 0; $dir = @opendir(XOOPS_ROOT_PATH.'/themes/'.$GLOBALS['xoopsConfig']['theme_set'].'/'.$path); while ( false !== ($filename = readdir($dir)) ) { if ( preg_match("/(.gif|.jpg|.png)$/", $filename) ) { // image filter $images[$i] = $filename; $i++; } } closedir($dir); mt_srand( (double)microtime() * 1000000 ); $choice = array_rand($images); return XOOPS_URL.'/themes/'.$GLOBALS['xoopsConfig']['theme_set'].'/'.$path.'/'.$images[$choice]; } <{/php}>
Then call the function when needed:
le="color: #000000"><?php <img src="<{php}> echo getRndImgURL('img/sidebar'); <{/php}>" alt="" width="158" height="116" /></div>
You can likely tailor this pretty easily to meet your needs. Good luck!