aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/functions_category.inc.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 67be45b0e..2e7ce2903 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -592,7 +592,26 @@ SELECT COUNT(DISTINCT(id)) AS nb_total_images
}
$conf['order_by'] = ' ORDER BY hit DESC, file ASC';
- $page['cat_nb_images'] = $conf['top_number'];
+
+ // $page['cat_nb_images'] equals $conf['top_number'] unless there
+ // are less visited items
+ $query ='
+SELECT COUNT(DISTINCT(id)) AS count
+ FROM '.IMAGES_TABLE.'
+ INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
+ '.$page['where'].'
+;';
+ $row = mysql_fetch_array(pwg_query($query));
+ if ($row['count'] < $conf['top_number'])
+ {
+ $page['cat_nb_images'] = $row['count'];
+ }
+ else
+ {
+ $page['cat_nb_images'] = $conf['top_number'];
+ }
+ unset($query);
+
if ( isset( $page['start'] )
and ($page['start']+$user['nb_image_page']>=$conf['top_number']))
{