diff --git a/core/imageboard/image.php b/core/imageboard/image.php index 598a2ab7..4f9d62ea 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -101,12 +101,15 @@ class Image return ($row ? new Image($row) : null); } - public static function by_random(array $tags=[]): ?Image + public static function by_random(array $tags=[], int $limit_range=0): ?Image { $max = Image::count_images($tags); if ($max < 1) { return null; } // From Issue #22 - opened by HungryFeline on May 30, 2011. + if ($max > $limit_range) { + $max = $limit_range; + } $rand = mt_rand(0, $max-1); $set = Image::find_images($rand, 1, $tags); if (count($set) > 0) { diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index 9d0e8a53..a66d8cc5 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -395,7 +395,7 @@ class TagList extends Extension } $h_tag = html_escape($row['tag']); $link = $this->tag_link($row['tag']); - $image = Image::by_random([$row['tag']]); + $image = Image::by_random([$row['tag']], 100); if (is_null($image)) { continue; } // one of the popular tags has no images