[image_view_counter] use Search::get_images() to take ratings etc into account and only showe popular images that the user can see - fixes #864

This commit is contained in:
Shish 2024-01-04 16:25:00 +00:00
parent 7673b394f4
commit 9e1f0e792d

View file

@ -94,19 +94,16 @@ class ImageViewCounter extends Extension
global $database;
if ($event->page_matches("popular_images")) {
$sql = "
$popular_ids = $database->get_col("
SELECT image_id, count(*) AS total_views
FROM image_views, images
WHERE image_views.image_id = image_views.image_id
AND image_views.image_id = images.id
GROUP BY image_views.image_id
ORDER BY total_views DESC
";
$result = $database->get_col($sql);
$images = [];
foreach ($result as $id) {
$images[] = Image::by_id(intval($id));
}
LIMIT 100
");
$images = Search::get_images($popular_ids);
$this->theme->view_popular($images);
}
}