{{indexmenu_n>10}} ====== random-image (template)====== ===== Displays a random image from image set of the file center ===== Docu: -- \\ Forum: [[http://forum.phpwcms.org/viewtopic.php?p=115291#p115291|Display random image from filemanager]] **Autor:** K.Heermann (flip-flop) http://planmatrix.de //2009/03/26 // \\ **CMS version:** >= V1.39 \\ **Version:** V1.0 \\ **Update:** -- \\ **Tag:** ##**--**## Filename: **random_image.tmpl** \\ Folder: ** /template/inc_cntpart/images/ ** **Condition:** ##$phpwcms['allow_cntPHP_rt'] = 1;## -> [[http://www.phpwcms-docu.de/conf_inc_php_en.phtml|/config/phpwcms/conf.inc.php]] ---- ---- \\ Inspired by the contribution of breitsch here is an other general solution using the template for "**image
**" or "**image special**". It is very pretty and more flexible: * list of images from CP * width/heigth parameters from CP * lightbox (zoom only doesn´t run!!!). * alt/title from CP * build your own classes/IDs * fallback image (please insert your image into the snippet at the end) * use [[http://www.phpwcms-docu.de/index.php?aid=36&highlight=show_content|{SHOW_CONTENT:....}]] for placing in your site template if you want \\
[PHP] $my_images = array(); $my_counter = -1; $my_counter++; $my_images[$my_counter][0] = '{IMAGE}'; // complete html string with image $my_images[$my_counter][1] = '{IMGID}'; // image-id echo '
'.LF; if (!empty($my_images) ) { echo '
'.LF; // ID // srand(microtime()*1000000); // Only for php version < 4.2 echo $my_images[rand(0,$my_counter)][0]; // iamge output echo '
'.LF; // End ID } else { // ************* Please insert your fallback image ************* echo 'My alt'; } echo '
'.LF; unset ($my_images); unset ($my_counter); [/PHP]
\\ ==== More features ==== If you wan´t more features, please play around with the other parameter like {THUMB_HEIGHT} or {IMAGE_HASH} and so on. ==== Parameters hand over ==== == from the range == $my_images[$my_counter][2] = '{THUMB_HEIGHT}'; // image-id $my_images[$my_counter][3] = '{THUMB_WIDTH}'; // image-id // and so on ....... == into the range == echo 'Test thumb height'.$my_images[$my_counter][2].'
'.LF; echo 'Test thumb width'.$my_images[$my_counter][3].'
'.LF;