From bdf274074c0f8bd8e52847c1170c4c14e9dc33b4 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 18 Jan 2012 03:13:27 +0000 Subject: [PATCH] some people like heading to the image after an image that isn't there (mostly robots with old URLs) --- ext/view/main.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ext/view/main.php b/ext/view/main.php index fc495cbc..56105a8e 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -87,6 +87,10 @@ class ViewImage extends SimpleExtension { } $image = Image::by_id($image_id); + if(is_null($image)) { + $this->theme->display_error($page, "Image not found", "Couldn't find image $image_id"); + } + if($event->page_matches("post/next")) { $image = $image->get_next($search_terms); } @@ -94,13 +98,12 @@ class ViewImage extends SimpleExtension { $image = $image->get_prev($search_terms); } - if(!is_null($image)) { - $page->set_mode("redirect"); - $page->set_redirect(make_link("post/view/{$image->id}", $query)); - } - else { + if(is_null($image)) { $this->theme->display_error($page, "Image not found", "No more images"); } + + $page->set_mode("redirect"); + $page->set_redirect(make_link("post/view/{$image->id}", $query)); } if($event->page_matches("post/view")) {