I have a little random image script:
<?php
///assets/images/headers/header-img1.jpg
$images = array();
$path = isset($scriptProperties['path']) ? MODX_ASSETS_PATH . $scriptProperties['path'] : MODX_ASSETS_PATH . 'images/';
if(count($images) == 0){
$images = glob($path. '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
}
shuffle($images);
$rand_img = str_replace(MODX_BASE_PATH, '', array_pop($images));
//$key = array_rand($images);
//$rand_img = str_replace(MODX_BASE_PATH, '', $images[$key]);
return $rand_img;
Pretty simple, grabs a random image from a path, however, if I try to call it more than once in a resource:
[[!randomImage? &path=`images/sidebars/`]]
[[!randomImage? &path=`images/sidebars/`]]
[[!randomImage? &path=`images/sidebars/`]]
it will return the same image all three times.
Is this something to do with modx caching?