diff --git a/ext/random_list/main.php b/ext/random_list/main.php
index 609766fb..46c49801 100644
--- a/ext/random_list/main.php
+++ b/ext/random_list/main.php
@@ -15,24 +15,43 @@ class RandomList extends Extension {
 		global $config, $page;
 
 		if($event->page_matches("random")) {
+			if(isset($_GET['search'])) {
+				// implode(explode()) to resolve aliases and sanitise
+				$search = url_escape(Tag::implode(Tag::explode($_GET['search'], false)));
+				if(empty($search)) {
+					$page->set_mode("redirect");
+					$page->set_redirect(make_link("random"));
+				}
+				else {
+					$page->set_mode("redirect");
+					$page->set_redirect(make_link('random/'.$search));
+				}
+				return;
+			}
+
+			if($event->count_args() == 0) {
+				$search_terms = array();
+			}
+			else if($event->count_args() == 1) {
+				$search_terms = explode(' ', $event->get_arg(0));
+			}
+			else {
+				throw new SCoreException("Error: too many arguments.");
+			}
+
 			// set vars
-			$page->title = "Random Images";
 			$images_per_page = $config->get_int("random_images_list_count", 12);
 			$random_images = array();
-			$random_html = "Refresh the page to view more images
-			
";
 
 			// generate random images
-			for ($i = 0; $i < $images_per_page; $i++)
-				array_push($random_images, Image::by_random());
+			for ($i = 0; $i < $images_per_page; $i++) {
+				$random_image = Image::by_random($search_terms);
+				if (!$random_image) continue;
+				array_push($random_images, $random_image);
+			}
 
-			// create html to display images
-			foreach ($random_images as $image)
-				$random_html .= $this->theme->build_thumb_html($image);
-
-			// display it
-			$random_html .= "
";
-			$page->add_block(new Block("Random Images", $random_html));
+			$this->theme->set_page($search_terms);
+			$this->theme->display_page($page, $random_images);
 		}
 	}
 
diff --git a/ext/random_list/theme.php b/ext/random_list/theme.php
index b3baf1ad..dd0f1d25 100644
--- a/ext/random_list/theme.php
+++ b/ext/random_list/theme.php
@@ -1,4 +1,56 @@
 search_terms = $search_terms;
+	}
+
+	/**
+	 * @param Page $page
+	 * @param Image[] $images
+	 */
+	public function display_page(Page $page, $images) {
+		$page->title = "Random Images";
+
+		$html = "Refresh the page to view more images";
+		if (count($images)) {
+			$html .= "";
+
+			foreach ($images as $image)
+				$html .= $this->build_thumb_html($image);
+
+			$html .= "
";
+		} else {
+			$html .= "
No images were found to match the search criteria";
+		}
+
+		$page->add_block(new Block("Random Images", $html));
+
+		$nav = $this->build_navigation($this->search_terms);
+		$page->add_block(new Block("Navigation", $nav, "left", 0));
+	}
+
+	/**
+	 * @param string[] $search_terms
+	 * @return string
+	 */
+	protected function build_navigation($search_terms) {
+		$h_search_string = html_escape(implode(" ", $search_terms));
+		$h_search_link = make_link("random");
+		$h_search = "
+			
+		";
+
+		return $h_search;
+	}
+}