the topic was lost, and I could find only first page of it.
1.
Open /includes/functions.php
Find:function get_random_image
Add after (below):global $cat_parent_cache;
1.2
Find: $category_id = $cat_id;
Add after:
$subcat_ids = array();
$subcats = get_subcat_ids($cat_id, $cat_id, $cat_parent_cache);
if (is_array($subcats) && is_array($subcats[$cat_id])) {
array_push($subcats[$cat_id], $cat_id);
global $cat_cache;
foreach ($subcats[$cat_id] as $key => $val)
{
if (!$cat_cache[$val]['num_images'])
{
unset($subcats[$cat_id][$key]);
}
}
$key = array_rand($subcats[$cat_id]);
$category_id = $subcats[$cat_id][$key];
$cat_id = $category_id;
}
1.3
Find: global $subcat_ids;
Replace with: global $subcat_ids, $cat_cache;
1.4
Find: if (check_permission("auth_viewcat", $val)) {
$subcat_ids[$cat_id][] = $val;
get_subcat_ids($val, $cat_id, $cat_parent_cache);
}
Replace with: if (check_permission("auth_viewcat", $val) && (!$field || ($field && $cat_cache[$val][$field]))) {
$subcat_ids[$cat_id][] = $val;
get_subcat_ids($val, $cat_id, $cat_parent_cache);
}
NOTE: your php version must be v4.2 or newer.
P.S. attached google cache page of the original post