[!easy2? &limit=`1` &orderby=`random` &rand_tpl=`4services.thumb`!]
// RANDOM IMAGE
if ($orderby == 'random' && $limit == 1) {
if (file_exists($rand_tpl)) {
$rand_tpl = file_get_contents($rand_tpl);
} elseif (!empty($modx->chunkCache[$rand_tpl])) {
$rand_tpl = $modx->chunkCache[$rand_tpl];
} else {
return 'Template not found!';
}
$res = mysql_query('SELECT * FROM '.$modx->db->config['table_prefix'].'easy2_files '
. 'WHERE status = 1 '
. ($rgid? 'AND dir_id='.$rgid.' ' : '')
. 'ORDER BY RAND() LIMIT 8');
$num_rows = mysql_num_rows($res);
if (!$num_rows) return;
$rand_output='';
while ($l = mysql_fetch_array($res, MYSQL_ASSOC)) {
$pos = strrpos($l['filename'], '.');
$ext = substr($l['filename'], $pos);
$l['title'] = $l['name'];
if ($l['name'] == '') $l['name'] = ' ';
elseif ($mbstring){
if (mb_strlen($l['name'], $charset) > $name_len) $l['name'] = mb_substr($l['name'], 0, $name_len-1, $charset).'...';
}
elseif (strlen($l['name']) > $name_len) $l['name'] = substr($l['name'], 0, $name_len-1).'...';
$l['w'] = $w;
$l['h'] = $h;
$path = get_path($l['dir_id']);
if (count($path) > 1) {
unset($path[1]);
$path = implode('/', array_keys($path)).'/';
} else {
$path = '';
}
$l['src'] = get_thumb($e2g['dir'], $path.$l['id'].$ext, $w, $h, $thq);
$rand_output.=filler($rand_tpl, $l);
}
return $rand_output;
}
// PATHS
[!easy2? limit=`1` &orderby=`random`!]
[!easy2? limit=`1` &orderby=`random`!]
if ($orderby == 'random' && $limit == 1)
[+easy2:back+]

Evo 1.0.2