{{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
[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 '';
}
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.
$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;